Roguewave error 9 [ENDOFFETCH] End Of Fetch - anyone know what this means?

351 views Asked by At

Ok, I'm dating my work with this question about a library I haven't coded in many years... I have code that has been in production since the late 1990s written in Visual Studio 6.0 C++ using Roguewave's DBTools++.

Suddenly, for a particular case, a query is failing and the RWDBStatus indicates error code 9, message is [ENDOFFETCH} End of Fetch. When I try to run the queries below with the appropriate keys, I get this odd error. Note - I will also be changing the code to be more specific about which query is failing, although it seems to be the second query that fails, as it only gets executed if the first query returned a value...

So, my question then is - does anyone know what "end of fetch" even means in this context? It is not currently cluing me into where to look for this one... Here is the error message, the code is below...

06/04/2014 16:00:40 FindSignature() - failed to execute!
06/04/2014 16:00:40 ErrorCode = 9,ErrorMsg  = [ENDOFFETCH] End of Fetch 
06/04/2014 16:00:40 VendCode1 = 0,VendCode2 = 0 
06/04/2014 16:00:40 VendMsg1 = ,VendMsg2 =  

Here is my code:

bool result = false;
RWDBTable tblRMSUsers = m_RMSDatabase.table( "RMSUsers" );
RWDBSelector selRecord = m_RMSDatabase.selector();
selRecord << tblRMSUsers["ExternalKey"];
selRecord.where( tblRMSUsers["InternalKey"] == lLinkToUser );
RWDBReader rdrRecord = selRecord.reader(theConnection);
if( rdrRecord() )
{
    RWCString s;
    rdrRecord >> s;
    // Changed to use view_SwitchUsers2 which includes deleted / inactive users...
    RWDBTable tblSwitchUsers = m_RMSDatabase.table( "view_SwitchUsers2" );
    RWDBSelector selRecord = m_RMSDatabase.selector();
    selRecord << tblSwitchUsers ["Signature"];
    selRecord.where( tblSwitchUsers ["SID"] == s );
    RWDBReader rdrRecord1 = selRecord.reader(theConnection);
    if(rdrRecord1 ())
    {
        rdrRecord1 >> blob;
        result = true;
    }
    else 
    {
         RWDBStatus theStatus = rdrRecord1.status();
         TraceStr("FindSignature() - failed to execute!");
         TraceStr("ErrorCode = %d,ErrorMsg  = %s ", theStatus.errorCode(), theStatus.message() );      
         TraceStr("VendCode1 = %d,VendCode2 = %d ", theStatus.vendorError1(), theStatus.vendorError2() );
         TraceStr("VendMsg1 = %s,VendMsg2 = %s ", theStatus.vendorMessage1(), theStatus.vendorMessage2() );
         return false;
    }

}

Any insights are appreciated!

2

There are 2 answers

0
Brian B On

Well, I cannot say exactly why I was getting this result. I can say that I ran the exact same SQL under the same user acct in Management Studio (it is a SQL Server 2008R2 DB) and all worked perfectly well...

Interestingly (there's always one of these "interesting" twists, yes?) the view being executed in the DB we are connected to is actually returning data queried from a fully qualified table in another DB on the same server. This view/query worked with all "older" records, but two recently added ones were causing an issue. But the issue was only occurring when the query was executed with the DBTools library...

I altered the view slightly (added WITH (NOLOCK) to make it more efficient, as there is no likelihood of dirty reads) and suddenly the issue went away. I suspect the act of altering it may have somehow affected an access plan?

I'm just elated the problem has gone away. Over a decade of using this code, and I've never seen this result ever... Wish I knew exactly what caused it and what fixed it, but probably never will...

1
gudnithor On

End of fetch is set as the status when there are no more results to read from the database.

Are you sure your query is not returning an empty result set?