Informix Error -26054: Cannot FREE a cursor (%s) that is in use
Cause and resolution
Cannot FREE a cursor (%s) that is in use
This FREE statement attempts to free a cursor that is still in use (i.e. not closed yet). Make sure to close this cursor by using the CLOSE statement before a FREE attempt.
Example
DECLARE c_cust CURSOR FOR s_cust;
OPEN c_cust USING lfname, llname; FETCH c_cust INTO lcustomer_num, lcompany; CLOSE c_cust;
FREE c_cust;
Oninit® Troubleshooting Guidance
Reasons / Common Causes
-26054 fires when FREE is issued on a cursor that hasn't been closed — per the official
guidance.
- The cursor targeted by
FREEis still open (not yet closed), per the official guidance — the direct, only cause.
Solutions / Resolution
CLOSEthe cursor beforeFREEing it, per the official guidance.
Examples
The correct CLOSE-before-FREE order
DECLARE c_cust CURSOR FOR s_cust;
OPEN c_cust USING lfname, llname;
FETCH c_cust INTO lcustomer_num, lcompany;
CLOSE c_cust;
FREE c_cust;
Diagnostic Checks
- Check the program logic for a
FREEon a cursor without a precedingCLOSE, and add the missingCLOSE.
Related Errors / Related Topics
- -26052 — "OPEN attempted on already opened cursor (%s)" A related cursor-lifecycle error, on reopening rather than freeing a still-open cursor.
- -26053 — "FETCH or CLOSE cannot reference cursor (%s) that is not opened" A related cursor-lifecycle error, on using an unopened cursor rather than freeing a still-open one.
FREE was issued on a cursor that's still open — CLOSE it first.