Informix Error -26053: FETCH or CLOSE cannot reference cursor (%s) that is not opened
Cause and resolution
FETCH or CLOSE cannot reference cursor (%s) that is not opened
The FETCH or CLOSE statement attempted to use an unopened cursor. Make sure to OPEN the cursor before attempting FETCH or CLOSE that cursor.
Example
OPEN c_cust USING lfname, llname; ... FETCH c_cust INTO lcustomer_num, lcompany; ... CLOSE c_cust;
Oninit® Troubleshooting Guidance
Reasons / Common Causes
-26053 fires when FETCH/CLOSE is issued on a cursor that isn't open — per the official
guidance.
- The
FETCH/CLOSEstatement's cursor was never opened, or was already closed, per the official guidance — the direct, only cause.
Solutions / Resolution
OPENthe cursor beforeFETCHing/CLOSEing it, per the official guidance.
Examples
The correct OPEN/FETCH/CLOSE order
OPEN c_cust USING lfname, llname;
...
FETCH c_cust INTO lcustomer_num, lcompany;
...
CLOSE c_cust;
Diagnostic Checks
- Check the program logic for
FETCH/CLOSEon a cursor without a precedingOPEN, and add the missingOPEN.
Related Errors / Related Topics
- -26052 — "OPEN attempted on already opened cursor (%s)" The mirror-image error, reopening an already-open cursor rather than fetching/closing an unopened one.
- -26054 — "Cannot FREE a cursor (%s) that is in use" A related cursor-lifecycle error, on freeing a still-open cursor rather than fetching/closing an unopened one.
FETCH/CLOSE was issued on a cursor that isn't open — OPEN it first.