[Cpp]
<Strong> c ++ reads and writes Clob objects. Pay attention to the data encoding length.
</Strong>
Read
// P_rs is resultset
If (p_rs-> next ())
{
Clob clob = p_rs-> getClob (4 );
If (! Clob. isNull ())
{
// Clob. setCharSetForm (OCCI_SQLCS_IMPLICIT); // The local encoding format seems to be incorrect.
Clob. setCharSetId ("UTF8"); // The database is stored in UTF-8
Unsigned int cloblen = clob. length ();
If (cloblen> 0)
{
Clob. open (OCCI_LOB_READONLY );
// UTF-8 must be multiplied by 3. Otherwise, only 1/3 of the actual data can be obtained.
Clob. read (cloblen * 3, (unsigned char *) msg_content, cloblen * 3, 1 );
Clob. close ();
}
}
}
Write
It should be written in varchar. There is no problem. Supports common SQL statements.
However, SQL statements have a limited length in oracle, so when the data is particularly long, you may need to consider using the Clob and write methods.
Author: RunBoying