需要把一个10万多字节字符串保存在数据库中,数据库中保存的格式为CLOB,希望谁能提供个例子。
// 第2步插入一条,CLOB列为空的数据
sql  = "  INSERT INTO CAS_SHM_DEAL_INFO ";
sql  += "  (LOG_ID,TABLE_ID,DEAL_INFO,CREATE_DATE) ";
sql  += " VALUES ";
sql  += "  (:LOG_ID,:TABLE_ID,:DEAL_INFO,SYSDATE) ";
    
m_stmt->setSQL(sql);
m_stmt->setMaxIterations(1);

//m_stmt->setMaxParamSize(1,sizeof(TYPE_INT));
     //m_stmt->setMaxParamSize(2,strlen((char*)sDealInfo.c_str())+2);
    
     m_stmt->setDouble(1,tmpLogId);
     m_stmt->setInt(2,iTableId);
     Clob clob(m_conn);
        clob.setEmpty();
     m_stmt->setClob(3,clob);
     m_stmt->executeUpdate();
    
     //第3步修改原有的CLOB列
     int nLength = strlen((char*)sDealInfo.c_str());
sql  = "  SELECT DEAL_INFO FROM CAS_SHM_DEAL_INFO ";
sql  += "  WHERE LOG_ID = :LOG_ID FOR UPDATE ";
     m_stmt->setSQL(sql);
     m_stmt->setDouble(1,tmpLogId);
    
     m_rs = m_stmt->executeQuery();
    
     if(m_rs->next())
     {
     cout<<" 1 "<<endl;
     clobwrite = m_rs->getClob(1);
     bClobOpen = true;
     cout<<" 2 "<<endl;
     strm = clobwrite.getStream();
     cout<<" 3 "<<endl;
     for(int nOffset=0;nOffset<nLength;nOffset=nOffset+1024)
{
cout<<" 3 1 "<<endl;
int nSize = (nLength-nOffset) > 1024 ? 1024 : nLength-nOffset;
cout<<" 3 2 nSize = "<<nSize<<endl;
//strm->writeBuffer((char*)sDealInfo.c_str()+nOffset,nSize);
cout<<" 3 3 "<<endl;
}
cout<<" 3 "<<endl;
clobwrite.closeStream(strm);
cout<<" 4 "<<endl;
strm = NULL;

//clobwrite.close();
     }
     cout<<" 5 1"<<endl;
     if (m_rs != NULL)
{
m_stmt->closeResultSet(m_rs);
m_rs = NULL;
}
    
     cout<<" 5 2"<<endl;
     m_conn->commit();
     cout<<" 6 "<<endl;我这个例子不能用,会报错误
 5 2
ex.getMessage() = ORA-03127: no new operations allowed until the active operation ends iTableId = 10119
 sql =   SELECT DEAL_INFO FROM CAS_SHM_DEAL_INFO   WHERE LOG_ID = :LOG_ID FOR UPDATE 
ORA-03127: no new operations allowed until the active operation ends