数据库读clob
在AIX上的多线程开发,char test[512000];用的栈空间,有2个这么大的变量,好像AIX只支持600K的栈,所以会core,想用堆空间,虽然oracle proc里面编译选项是CPP,可是不让我char *test = new char[512000];
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;}