-501 THE CURSOR IDENTIFIED IN A FETCH OR CLOSE STATEMENT IS NOT OPEN
Explanation
The application program attempted either to fetch using a cursor or to close a cursor at a time when the specified cursor was not open.
System action
The statement cannot be processed.
Programmer response
Check for a previous SQL return code that might have closed the cursor.
- Commit and rollback operations close cursors.
- SQL return codes -404, -652, -679, -802, -901, -904, -909, -910, -911, -913, and -952 might force the cursor to close.
- An error SQLCODE during predicate processing closes the cursor.
After the cursor is closed, any fetches or close cursor statements will receive SQLCODE -501.
If no previous SQL return codes have been issued, correct the logic of the application program to ensure that the cursor is open at the time the FETCH or CLOSE statement is processed.
SQLSTATE
24501