当前位置: 代码迷 >> AIX >> 数据库读clob解决办法
  详细解决方案

数据库读clob解决办法

热度:7943   发布时间:2013-02-26 00:00:00.0
数据库读clob
在AIX上的多线程开发,char test[512000];用的栈空间,有2个这么大的变量,好像AIX只支持600K的栈,所以会core,想用堆空间,虽然oracle proc里面编译选项是CPP,可是不让我char *test = new char[512000];
C/C++ code
int CEntityBase::readClob(OCIClobLocator *p_clob, char* buff){        struct sqlca sqlca;    EXEC SQL CONTEXT USE:m_pWorkThread->m_pvSqlCtx;        EXEC SQL BEGIN DECLARE SECTION;                OCIClobLocator *clob;                varchar *lvr;                int amt;                int bufsize;        EXEC SQL END DECLARE SECTION;        #if 0    if(sqlca.sqlcode != 0)        {                return sqlca.sqlcode;        }        #endif    bufsize = 2048;        clob = p_clob;        char* tmp = new char[2 + bufsize];        memset(tmp, 0, 2+bufsize);        lvr = (varchar *)tmp;        lvr->len = bufsize;        int len = 0;        amt = 0;        EXEC SQL WHENEVER NOT FOUND DO break;        while (TRUE)        {                memset(lvr,0,2+bufsize);                EXEC SQL LOB READ :amt FROM :clob INTO :lvr WITH LENGTH :bufsize;                strcat(buff, (char *)lvr->arr);//        memcpy(buff + len, lvr->arr, lvr->len);//        len += lvr->len;        }        EXEC SQL WHENEVER NOT FOUND CONTINUE;        strcat(buff, (char *)lvr->arr);//    memcpy(buff + len, lvr->arr, lvr->len);//    len += lvr->len;//    buff[len] = 0;        delete[] tmp;    return 0;}

OCIClobLocator *sbillpic1data_VALUE;
readClob(sbillpic1data_VALUE, test);
CUFcString a = test;
其实就是最后想把test赋值给a,

------解决方案--------------------------------------------------------
试试定义为静态变量
static char test[512000]
------解决方案--------------------------------------------------------
malloc啊
------解决方案--------------------------------------------------------
其实是数据库的问题,跟是否为 aix 没有关系。
  相关解决方案