oracle c++ 中的 SOCI clob 数据类型

SOCI clob data type in oracle c++

有人能说说如何在 SOCI C++ 中处理 CLOB 数据类型吗?

我想知道如何使用 C++ SOCI 读取 oracle 中的 CLOB 数据列值。

我尝试在 SOCI 中使用 BLOB 类型,但出现错误。 Oracle 错误 932:预期 %s 的数据类型不一致得到 %s 错误

我在 google 测试中使用了 following,它对我有用,

// 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);

将 clob 类型的数据绑定到 soci 语句时,使用 soci::long_string 而不是 std::string。因为,如果在使用 soci 将 clob 数据写入 table 时使用 std::string 绑定 clob 数据,则 soci 库将该数据视为 varchar2 类型而不是 clob 类型。 varchar2 数据类型不能用于存储大型 data.Usage of std::string 类型的容器,将 clob 数据绑定到 soci 语句可能会导致数据丢失。