'How to retrieve CLOB data when NLS_CHARACTERSET=AL32UTF8
I have written a c++ code to write and read clob data to/from oracle database. When nls database parameters like below this runs perfectly.
NLS_NCHAR_CHARACTERSET = AL16UTF16
NLS_CHARACTERSET = WE8MSWIN1252
(Using connection string = "oracle://service=abc user=abc password=abc charset=178 ncharset=1000")
However, when database nls parameters are like these code return and soci error: Unknown error code while executing "select s from long_string_test where id = 1
NLS_NCHAR_CHARACTERSET = AL16UTF16
NLS_CHARACTERSET = AL32UTF8
std::string DbConnectionString = "oracle://service=abc user=abc password=abc charset=873 ncharset=1000";
soci::session dbCon;
dbCon.open(DbConnectionString.c_str());
int id = 1;
soci::xml_type xml;
xml.value = "<file>";
for (int i = 0; i != 200; ++i)
{
xml.value += "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
}
xml.value += "</file>";
// additional test for empty and non-empty long_string
dbCon << "create table long_string_test (id integer, s clob)";
soci::long_string s1; // empty
dbCon << "insert into long_string_test(id, s) values (1, :s)", use(s1);
soci::long_string s2;
s2.value = "test value";
dbCon << "select s from long_string_test where id = 1", into(s2);
s1.value = xml.value;
dbCon << "update long_string_test set s = :s where id = 1", use(s1);
dbCon << "select s from long_string_test where id = 1", into(s2);
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
