![通过OCI 处理 Oracle 10g 中处理Clob大字段写入 通过OCI 处理 Oracle 10g 中处理Clob大字段写入](https://image.shishitao.com:8440/aHR0cHM6Ly9ia3FzaW1nLmlrYWZhbi5jb20vdXBsb2FkL2NoYXRncHQtcy5wbmc%2FIQ%3D%3D.png?!?w=700&webp=1)
Oracle数据库中, 通过存储过程写入Clob字段 , 当数据大于4k时, 报错
ORA-01460: 转换请求无法实施或不合理
经过排查, 数据Bind方式不对, 不能采用字符串的Bind方式
原方式
//CHECK_SUCCESS(nRet, OCI_BindString(st, MT(":xmlinfo"), data, len), m_Error, clear);
修改后方式
OCI_Lob *lob=NULL;
CHECK_SUCCESS_A(lob, OCI_LobCreate(m_conn, OCI_CLOB), m_Error, clear);//Create a local temporary Lob instance
count= getWordCounts(data);
length = static_cast<unsigned int>(strlen(data));
CHECK_SUCCESS(nRet, OCI_LobWrite2(lob, (dtext *)data, &count, &length), m_Error, clear);
CHECK_SUCCESS(nRet, OCI_BindLob(st, MT(":xmlinfo"), lob), m_Error, clear);