When using the SQL_MoveFirsB, SQL_MoveNextB, SQL_MoveLastB, and SQL_MovePrevB functions, the returned value *ERROR* usually means end-of-file (EOF). However, it is possible for other errors to occur. For a consistent check for EOF, use the SQL_LastFullErr function.

To check for end-of-file (EOF):

  1. Connect to the RPG2SQL PC Component.
  2. Receive a socket in variable SQL_Socket.
  3. Retrieved the record into the variable rtnRecord.
  4. Use the following code to check for EOF:
    /free
     // If error indicated, see if it's BOF/EOF
     if rtnRecord = '*ERROR*';
       errMsg = SQL_LastFullErr(stateDS.socketSel);
    
       if (errMsg = '-1 End of file reached.' or
           errmsg = '-2 Beginning of file reached.');
         pEof = *on;
       endIf;
    
     endIf;
    /end-free

Still have questions? We can help. Submit a case to Technical Support.

Last Modified On: December 10, 2016