Informix Error -507: Cursor cursor-name not found.
Cause and resolution
Cursor cursor-name not found.
The cursor that is named in the WHERE CURRENT OF clause in this UPDATE or DELETE statement does not exist. Review the spelling of the name. If it is as you intended, check the DECLARE statement to ensure that it has been executed. Also make sure that the cursor has not been freed with the FREE statement or during a failed automatic re-prepare attempt.
Oninit® Troubleshooting Guidance
Reasons / Common Causes
-507 fires when an UPDATE ... WHERE CURRENT OF cursor-name or DELETE ... WHERE CURRENT OF cursor-name names a cursor the server can't find open under that name.
- A misspelled cursor name in the
WHERE CURRENT OFclause — the official guidance's first suggested check. - The cursor's
DECLAREwas never actually executed before the positioned UPDATE/DELETE ran, so the name was never registered. - The cursor was explicitly closed with
FREEbefore the positioned statement executed. - A failed automatic re-prepare silently dropped the cursor — per the official guidance, this
is a documented way a cursor can disappear without an explicit
FREE.
Solutions / Resolution
- Review the spelling of the cursor name, per the official guidance, against the name used
in its
DECLARE. - Confirm the
DECLAREstatement actually executed before the positioned UPDATE/DELETE, per the official guidance — check for an earlier error that may have skipped it. - Check whether the cursor was freed, per the official guidance, either explicitly via
FREE cursor-nameor implicitly through a failed automatic re-prepare, and re-declare/re-open it if so.
Examples
Misspelled cursor name
DECLARE order_cursor CURSOR FOR SELECT * FROM orders FOR UPDATE;
OPEN order_cursor;
FETCH order_cursor INTO ...;
UPDATE orders SET status = 'shipped' WHERE CURRENT OF orders_cursor;
-- -507: 'orders_cursor' was never declared; the real name is 'order_cursor'
Cursor freed before use
DECLARE order_cursor CURSOR FOR SELECT * FROM orders FOR UPDATE;
OPEN order_cursor;
FREE order_cursor;
UPDATE orders SET status = 'shipped' WHERE CURRENT OF order_cursor;
-- -507: the cursor no longer exists
Diagnostic Checks
- Trace the cursor's
DECLARE/OPEN/FREElifecycle in the surrounding code to confirm it is still open at the point of the positioned UPDATE/DELETE. - Check for an earlier failed statement (including a failed automatic re-prepare) that could
have prevented the
DECLAREfrom taking effect or freed the cursor implicitly.
Related Errors / Related Topics
No closely related error codes are cross-referenced for -507 in this set yet.
The cursor named in WHERE CURRENT OF isn't currently open under that name — check spelling
first, then whether it was ever declared or was freed (explicitly or via a failed re-prepare).