-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 whether the cursor was closed by one of the following situations. After a cursor is closed, any subsequent FETCH or CLOSE statement for the cursor receives SQLCODE -501.
- A previous CLOSE statement
- A commit or rollback operation
- An error when accessing an unavailable object, such as -679, -901, -904, -909, -910, -911, -913, or -952
- An error when attempting to update an object, such as -404 or -652
- An arithmetic error when processing an aggregate function, such as -802
- An error during predicate processing
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