SOCI clob data type in oracle c++

709 views Asked by At

can someone say how to handle CLOB datatype in SOCI C++?

I want to know how to read CLOB data column values in oracle using C++ SOCI.

I tried to use BLOB type in SOCI but It gives an error. Oracle error 932: inconsistent datatypes expected %s got %s ERROR

2

There are 2 answers

0
Chathura Wick On BEST ANSWER

I have used following with google test and it works for me,

// insert clob
std::string str = "string as clob";
dbSession << "INSERT INTO CLOB_TABLE (ID, DATA) VALUES(:a, :b)",soci::use(1, "a"), soci::use(str, "b");    

// read clob
dbSession << "SELECT DATA FROM CLOB_TABLE WHERE ID = 1", soci::into(str);
0
ShaL On

Use soci::long_string instead of std::string when binding clob typed data to soci statement. Because, if clob data is bound using std::string while writing clob data into a table using soci, soci library consider that data as a varchar2 type instead of clob type. varchar2 data type cannot use to store large data.Usage of std::string typed container to bind clob data to soci statement can be caused to data lost.