Fetch Next not working in recursive function

Jeremy Biros

Well Known Member
Hello. I have a recursive function that travels the Bill of Material from child up to highest parent (01 item) for every child item in F4102. When it reaches each highest parent, it calls another function to sum up all qty on open sales orders for that item. This is where the problem is. My F4211.Select works fine. I've checked the actual SQL statement generated in the debug log and ran it in Query Analyzer. It returned what I expected it to return. However, when it gets to the first F4211.Fetch Next, it does not fetch any records, and does not enter my fetch loop (While SV File IO Status = CO_SUCCESS).

Here is the Fetch Next statement as it appears in my .c source file:
<font class="small">Code:</font><hr /><pre>
/* F4211.Fetch Next */
pAppVars->iTableRetCode = RTK_CER_FIOOpen( hUser ,
"F4211" , 1L , 0 , &hReqF4211_1T );
if ( hReqF4211_1T == NULL )
{
pAppVars->iTableRetCode = TABLE_NOT_OPEN;
}
else
{
if ( JDB_Fetch( hReqF4211_1T , &zF4211_29 , 0 ) != JDEDB_PASSED )
{
JDB_ClearSelection( hReqF4211_1T );
JDB_ClearSequencing( hReqF4211_1T );
pAppVars->iTableRetCode = ER_ERROR;
}
else
{
jdeStrcpy( evt_szCurrentOrderType_DCTO , zF4211_29.sddcto ,
sizeof( evt_szCurrentOrderType_DCTO ) );
MathCopy( &evt_mnCurrentSOQty_UORG , &zF4211_29.sduorg );
pAppVars->iTableRetCode = ER_SUCCESS;
}
}
</pre><hr />

The statement that evaluates as true is:
<font class="small">Code:</font><hr /><pre>
JDB_Fetch( hReqF4211_1T , &zF4211_29 , 0 ) != JDEDB_PASSED
</pre><hr />

Thus, it never actually fetches a record. I've added .Close table I/O statements for all of my tables in case the recursion left too many open cursors for the same table. This did not help. I've rewritten my Select and Fetch Next statements and verified their parameters in the debugger. They are all what I expect them to be. Any help or suggestions would be greatly appreciated.
 
Figured it out. My Select statement was using a different index than my Fetch Next statement was using.
 
Back
Top