OCI批量获取Select结果,记录数为0
char *sqlstr = "select count(*) from foo";
static ub4 FpreFetch = 10;
int rowCount;
//装载查询语句
rc = OCIStmtPrepare(pSql, pErr, (OraText*)sqlstr, strlen(sqlstr), OCI_NTV_SYNTAX, OCI_DEFAULT);
rc = OCIAttrSet(pSql, OCI_HTYPE_STMT, &FpreFetch, (ub4)sizeof(ub4), OCI_ATTR_PREFETCH_ROWS, pErr);
rc==0?NULL:err_handler(pErr);
rc = OCIStmtExecute(pCtx, pSql, pErr, (ub4)NULL, (ub4)NULL, NULL, NULL, OCI_RESULT_CACHE);
rc==0?NULL:err_handler(pErr);
rc = OCIAttrGet(pSql, OCI_HTYPE_STMT, &rowCount, NULL, OCI_ATTR_ROWS_FETCHED, pErr);//
rc==0?NULL:err_handler(pErr);
rc = OCIAttrGet(pSql, OCI_HTYPE_STMT, &rowCount, NULL, OCI_ATTR_ROW_COUNT, pErr);//结果集行数
rc==0?NULL:err_handler(pErr);
程序执行时我表中有20条记录,但是两个rowCount都是0。希望了解OCI的朋友指点一下。
OCI 批量获取数据 结果为0
分享到:
------解决方案--------------------
Program Name Features Illustrated
cdemo81.c Using basic SQL processing with release 8 and later functionality.
cdemo82.c Performing basic processing of user-defined objects.
cdemocor.c Using complex object retrieval (COR) to improve performance.
cdemodr1.c,cdemodr2.c,cdemodr3.c Using INSERT/UPDATE/DELETE statements with RETURNING clause used with basic datatypes, LOBs and REFs.