Informix Error -266
-266 There is no current row for UPDATE/DELETE cursor.
The current statement uses the WHERE CURRENT OF cursor-name clause, but that cursor has not yet been associated with a current row. Either no FETCH statement has been executed since it was opened, or the most recent fetch resulted in an error so that no row was returned. Revise the logic of the program so that it always successfully fetches a row before it executes this statement.
Oninit® Troubleshooting Guidance
Reasons / Common Causes
-266 is the SQL-layer counterpart to -112's ISAM-level "no current record" — a
WHERE CURRENT OF cursor-name clause was used, but the cursor isn't currently associated with a
row.
- No
FETCHhas been executed since the cursor was opened —WHERE CURRENT OFneeds a successful prior fetch to establish what "current" refers to. - The most recent
FETCHresulted in an error, so no row was actually returned, but the code proceeded toWHERE CURRENT OFanyway. - An unchecked
FETCHreturn value — the same root-cause pattern as -112: a failed or end-of-data fetch going unchecked before the code proceeds to reference the (nonexistent) current row.
Solutions / Resolution
- Revise program logic so a
FETCHalways succeeds beforeWHERE CURRENT OFexecutes, per the official guidance. - Check the
FETCHreturn code explicitly — don't proceed toWHERE CURRENT OFif the fetch failed or reached end of data.
Examples
WHERE CURRENT OF without a prior fetch
DECLARE cur1 CURSOR FOR SELECT * FROM orders WHERE status = 'pending' FOR UPDATE;
OPEN cur1;
UPDATE orders SET status = 'processing' WHERE CURRENT OF cur1;
-- -266: no FETCH ran since OPEN — there's no current row yet
Fix:
OPEN cur1;
FETCH cur1 INTO :rec;
UPDATE orders SET status = 'processing' WHERE CURRENT OF cur1;
An unchecked failed fetch
FETCH cur1 INTO :rec; /* fails — end of data, iserrno/SQLCODE not checked */
UPDATE orders SET status = 'processing' WHERE CURRENT OF cur1;
-- -266: the FETCH didn't establish a current row
Diagnostic Checks
- Review the call sequence immediately before the failing
WHERE CURRENT OF— was there aFETCHon the same cursor, and did it succeed? - Check whether the prior
FETCH's return code was actually checked — an unchecked failure there is the most common actual root cause.
Related Errors / Related Topics
- -112 — "ISAM error: there is no current record." The ISAM-level counterpart to this exact same condition.
- -259 — "Cursor not open." Another cursor-lifecycle condition in the same general family.
Check for an unchecked, failed FETCH immediately before the failing statement — that's the
most common actual root cause, exactly as with -112.