简体   繁体   English

Oracle C ++中的SOCI Clob数据类型

[英]SOCI clob data type in oracle c++

can someone say how to handle CLOB datatype in SOCI C++? 有人可以说如何在SOCI C ++中处理CLOB数据类型?

I want to know how to read CLOB data column values in oracle using C++ SOCI. 我想知道如何使用C ++ SOCI在Oracle中读取CLOB数据列值。

I tried to use BLOB type in SOCI but It gives an error. 我试图在SOCI中使用BLOB类型,但是给出了错误。 Oracle error 932: inconsistent datatypes expected %s got %s ERROR Oracle错误932:预期%s不一致的数据类型得到%s错误

I have used following with google test and it works for me, 我已经在Google测试中使用了以下功能,它对我有用,

// 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. soci::long_string类型的数据绑定到soci语句时,请使用soci::long_string而不是std::string 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. 因为,如果在使用soci将clob数据写入表时,使用std :: string绑定clob数据,则soci库会将数据视为varchar2类型而不是clob类型。 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. varchar2数据类型不能用于存储大数据。使用std :: string类型的容器将clob数据绑定到soci语句可能会导致数据丢失。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM