SQL Error -500 -Cursor was closed when the connection destroyed

Explanation:

The FETCH, UPDATE, DELETE, or CLOSE statement identifies a closed cursor that was defined with the WITH HOLD option.

The cursor was closed when the connection on which it was dependent was destroyed during a commit operation. The connection was destroyed because the application process placed it in the released state, or the application plan was bound with the DISCONNECT(AUTOMATIC) option.

System action

The statement cannot be processed.

Resolution

  • If you want the cursor closed, change the application program so that the cursor is not referenced in the closed state.
  • If you want the cursor open and the connection was placed in the released state by the application program, change the program so that the connection is not placed in the released state until the cursor is explicitly closed.
  • If you want the cursor open and the connection was placed in the released state as a result of the DISCONNECT(AUTOMATIC) option, rebind the plan using DISCONNECT(CONDITIONAL).

Correct the error in the application, rebind the plan, and resubmit the job.

Author: Srini

Experienced software developer. Skills in Development, Coding, Testing and Debugging. Good Data analytic skills (Data Warehousing and BI). Also skills in Mainframe.