0

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

Ratan Uday Kumar
  • 5,738
  • 6
  • 35
  • 54
Noah
  • 55
  • 7

2 Answers2

0

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

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.

ShaL
  • 141
  • 6