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
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);
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.