otl_lob_stream does not have any specific constructor by which an actual instance of otl_lob_stream can be created. Instead, the stream gets initialized by writing / reading an otl_lob_stream variable to / from the otl_stream.
Potentially, the otl_lob_stream class may raise an OTL defined exception.
class otl_lob_stream {
public:
| Function
/ data member |
Description |
void set_len(const int alen); |
Sets the
total number of bytes (or Unicode
characters)
to be written to the otl_lob_stream. In other words, set the total size
of the LOB. The total length of the LOB normally needs to set before
the first LOB chunk should be written into the otl_lob_stream. However, OTL 4.0.138 and higher does not require that. OTL/ODBC/DB2-CLI completely relaxes that requirement. OTL/OCI8i/9i/10g/11g does not require that, if the last LOB chunk / piece in the sequence is indicated through a call to otl_long_string::set_last_piece(true). |
| otl_lob_stream&
operator<< (const std::string& s); |
Writes
the whole CLOB / TEXT /
VARCHAR(MAX), etc. into the stream. Declared, when OTL_STL is defined and OTL_UNICODE is not defined |
| otl_lob_stream& operator<< (const ACE_TString& s); |
Writes the whole CLOB /
TEXT /
VARCHAR(MAX), etc. into the stream. Declared, when OTL_ACE is defined and OTL_UNICODE is not defined. |
| otl_lob_stream& operator>>(std::string& s); |
Reads
the whole CLOB / TEXT / etc. from
the stream into a string Declared, when OTL_STL is defined and OTL_UNICODE is not defined. |
| otl_lob_stream& operator>> (ACE_TString& s); |
Reads the whole CLOB / TEXT /
etc. from
the stream into a string Declared, when OTL_ACE is defined and OTL_UNICODE is not defined |
| void
setStringBuffer (const int chunk_size); |
Sets an internal buffer of "chunk_size" to help reduce the number of calls to string::operator +=() in the operators >>() above. The bigger the buffer, the fewer the calls to the +=() to concatenate chunks of the CLOB value to the output string. |
otl_lob_stream& operator<< |
Writes a chunk of the LOB into the stream. |
otl_lob_stream& operator<< |
Writes a chunk of the Unicode
LOB into the
stream. Declared, when OTL_UNICODE is not defined |
otl_lob_stream& operator>> |
Reads a chunk of LOB from the stream. |
otl_lob_stream& operator>> |
Reads a chunk of Unicode LOB
from the stream. Declared, when OTL_UNICODE is not defined. |
int len(); |
Gets the length of the LOB to be
read in bytes, or in Unicode
characters..
In OTL/OCI8/8i/9i, the actual length of the LOB is available
immediately
after the intialization of the stream. In OTL/ODBC and OTL/DB2-CLI, the
function returns 0 before the first chunk of the LOB is read, and it
returns
the actual length of the LOB after the first chunk of the LOB is
read. This difference is due to the differences in behavior of the underlying database APIs. So, for writing portable [across multiple databases] code, it is recommended to use this function carefully. |
int eof(); |
Checks the stream for "end-of-file" condition |
void close(); |
Closes the stream. |
| bool is_initialized(); | Checks if the LOB in the stream is initialized or not. Say, an Oracle PL/SQL block binds an output :f2<clob>, and, when the block gets executed, the actual CLOB doesn't get initialized. The function will return false in this case. |
}; // end of otl_lob_streamThe ODBC as well as DB2 CLI standards recommend that LOBs should be put at the end of INSERT/SELECT statements. For example:
INSERT INTO my_tab (f1,f2,f3_lob,f4_lob)...
SELECT f1,f2,f3_lob,f4_lob FROM my_tab...
The recommendation applies especially in the case of piece-wise data operations, that is, in the OTL LOB stream mode. At the same time, the standards say that it is up to the ODBC drivers/database APIs to either enforce or not to enforce that rule. The LOB's part of OCI8 in Oracle does not require that kind of thing, so it is really up to the developer to decide what to do. However, the general recommendation for writing portable code, that uses the LOB stream mode, would be to put LOBs at the end of the column lists in INSERT or SELECT statements.
In order to use the otl_lob_stream class for OTL/ODBC and OTL/DB2-CLI, a call to otl_stream::set_lob_stream_mode() is required.
Also, see example 56, 57, 122, 123, 124, 125, 126, 127, 128, 129.
Copyright © 1996-2009, Sergei Kuchin, email: skuchin@aceweb.com, skuchin@gmail.com .
Permission to use, copy, modify and redistribute this document for any purpose is hereby granted without fee, provided that the above copyright notice appear in all copies. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.