OCIStmtFetch2 problem when fetched rows = 0 [message #504554] |
Tue, 26 April 2011 09:42 |
|
eiland
Messages: 2 Registered: April 2011
|
Junior Member |
|
|
I looping through a SELECT query result with OCIStmtFetch2 to get all the fetched result rows.
Everything is working great, I am using a buffer sized (1024 * rowSize) and having no problem when the number of returned rows is less or more then 1024, the problem occurs when this number is exactly a multiplier of 1024.
Lets say I know the number of rows that will return from the SELECT query is 1024. A first run of OCIStmtFetch2 returns with OCI_SUCCUSS and the buffer is filled with correct info. Then a 2nd execution of OCIStmtFetch2 is done which fetched 0 rows and THIS action is messing up something that makes all the already returned data corrupted.
(I know this, because getting 1024 without calling OCIStmtFetch2 a second time works)
Thanks in advance.
the code (only for calling OCIStmtFetch2, looping is done outside):
rcForFetch = OCIStmtFetch2(i_dbContext.m_pSelect, i_dbContext.m_pError, 1024 , OCI_DEFAULT, 0, OCI_DEFAULT);
switch (rcForFetch)
{
case OCI_NO_DATA:
{
ub4 rows;
rcForFetch = OCIAttrGet (i_dbContext.m_pSelect, OCI_HTYPE_STMT, &rows, 0, OCI_ATTR_ROWS_FETCHED, i_dbContext.m_pError);
if (OCI_SUCCESS != rcForFetch)
{
// Get oracle error
rcForFetch = OCIErrorGet(i_dbContext.m_pError, 1, 0, &codeForFetch, (text*)errbufForFetch, sizeof(errbufForFetch), OCI_HTYPE_ERROR);
if (OCI_SUCCESS == rcForFetch)
{
//201 - CPPGEN - DATA_LAYER - FAILED_TO_EXECUTE_BATCH
CPF_LOG_MSG(m_pCreator->m_pLogger, afc::LogLevel::ms_ERROR, "FAILED_TO_EXECUTE_ATTR_GET.\n Error (<1>):\n <2>", rcForFetch << i_dbContext.m_lastDBError);
}
else
{
//205 - CPPGEN - DATA_LAYER - FAILED_TO_EXECUTE_BATCH_NO_ERROR_AVAILABLE
CPF_LOG_MSG_NO_PARAMS(m_pCreator->m_pLogger, afc::LogLevel::ms_ERROR, "FAILED_TO_EXECUTE_ATTR_GET_NO_ERROR_AVAILABLE");
}
return Common::rcDB_ERROR;
}
o_extracted = static_cast<cpf::UInt32>(rows);
o_lastFetch = true;
return Common::rcSUCCESS;
}
break;
case OCI_SUCCESS:
case OCI_SUCCESS_WITH_INFO:
{
o_extracted = i_bufferSize;
o_lastFetch = false;
return Common::rcSUCCESS;
}
break;
default:
....
|
|
|
|
|