Home » Developer & Programmer » Precompilers, OCI & OCCI » OCIStmtFetch2 problem when fetched rows = 0
OCIStmtFetch2 problem when fetched rows = 0 [message #504554] Tue, 26 April 2011 09:42 Go to next message
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:
....
Re: OCIStmtFetch2 problem when fetched rows = 0 [message #504726 is a reply to message #504554] Wed, 27 April 2011 08:29 Go to previous messageGo to next message
eiland
Messages: 2
Registered: April 2011
Junior Member
NVM that ^ Confused my mistake

It was all a convert of INT field in win32 problem , something in the outside function

So yeah this topic can be delete, sry for spamming Razz

[Updated on: Wed, 27 April 2011 08:30]

Report message to a moderator

Re: OCIStmtFetch2 problem when fetched rows = 0 [message #504736 is a reply to message #504726] Wed, 27 April 2011 08:58 Go to previous message
Michel Cadot
Messages: 68624
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Thanks for the feedback anyway.
It is good to know the root of the problem, maybe someone will have something close to it or maybe it will give some ideas to check.

Regards
Michel
Previous Topic: Multithreading/Pro*C Insert Issue
Next Topic: OCIRaw Array Bind
Goto Forum:
  


Current Time: Thu Mar 28 10:01:12 CDT 2024