-353   FETCH IS NOT ALLOWED, BECAUSE CURSOR cursor-name HAS AN UNKNOWN POSITION

Explanation

The cursor position for cursor-name is unknown. The previous multiple-row-fetch for cursor cursor-name resulted in an error in the middle of processing multiple rows that were retrieved from DB2®. One or more of the requested rows could not be returned to the program following the error, leaving the position of the cursor unknown.

The error might have been detected at the requester. For example, a row with a null value was returned to an application, but no indicator variable was provided. A subsequent FETCH statement would result in SQLCODE -353. If an indicator had been provided, a positive SQLCODE would have been returned and all of the rows retrieved from DB2 could have been returned to the application program.

System action

The statement cannot be processed. The cursor position is not changed.

Programmer response

Close and reopen the cursor to reset the cursor position. For scrollable cursors, you can change the FETCH statement to specify one of the other fetch orientations. For example, you can modify the FETCH statement by specifying one of the following fetch orientations:
  • BEFORE or AFTER
  • row-positioned fetch orientations: FIRST, LAST, or ABSOLUTE to establish a valid row cursor and fetch a row of data
  • rowset-positioned fetch orientations: FIRST ROWSET, LAST ROWSET, or ROWSET STARTING AT ABSOLUTE to establish a valid rowset cursor position and fetch multiple rows of data

Alternately, change the application to correct the error that originally occurred. For example, if the error was issued because an indicator was not provided, change the application to provide an indicator.

SQLSTATE

24513