c++ 读写Clob对象,注意数据编码长度 读 //p_rs 为resultset if (p_rs->next()) { Clob clob = p_rs->getClob(4); if (!clob.isNull()) { //clob.setCharSetForm(OCCI_SQLCS_IMPLICIT); //本地编码格式,貌似有问题 clob.setCharSetId("UTF8"); //数据库是utf-8存储的 unsigned int cloblen = clob.length(); if (cloblen > 0) { clob.open(OCCI_LOB_READONLY); //utf-8必须乘以3,不然只能取实际数据的1/3 clob.read(cloblen * 3, (unsigned char*)msg_content, cloblen * 3, 1); clob.close(); } } } 写 就当是varchar来写,没有问题。普通的sql支持。 不过sql语句在oracle里面是有长度限制的,所以当数据特别长的时候,可能要考虑使用Clob加write方法来搞定。