Informix Error -423
-423 A FETCH CURRENT was attempted with no current row.
This FETCH statement asks for the current row, but none exists. Either the cursor was just opened, or the previous fetch returned an error code, perhaps because it was at the end of the data. Review the program logic, and check that it uses a FETCH NEXT statement or other FETCH operation to establish a current row before it attempts this statement.
Oninit® Troubleshooting Guidance
Reasons / Common Causes
-423 fires when FETCH CURRENT is issued without a current row already established on the
cursor — FETCH CURRENT re-fetches whatever row the cursor is already positioned on, so it needs
a prior successful positioning fetch (FETCH NEXT, FETCH FIRST, and similar) to have happened
first.
FETCH CURRENTissued immediately afterOPEN, before any positioning fetch has established a current row.FETCH CURRENTissued after a failed fetch — most commonly after reaching end-of-data on a priorFETCH NEXT, which leaves no current row to re-fetch.- Application error-handling logic that doesn't distinguish between "still positioned on a
row" and "just hit end-of-data" before attempting a
FETCH CURRENTretry.
Solutions / Resolution
- Ensure
FETCH NEXT(or another positioning fetch) establishes a current row before attemptingFETCH CURRENT, per the official guidance. - Check the return status of the prior fetch before attempting
FETCH CURRENT— if the prior fetch hit end-of-data or otherwise failed, there's no current row to re-fetch. - Review program logic around retry loops that might attempt
FETCH CURRENTafter an unsuccessful positioning fetch.
Examples
FETCH CURRENT immediately after OPEN
DECLARE curs1 CURSOR FOR SELECT * FROM orders;
OPEN curs1;
FETCH CURRENT curs1;
-- -423: no current row yet; OPEN alone doesn't position the cursor
Fix — position with FETCH NEXT first:
OPEN curs1;
FETCH NEXT curs1;
FETCH CURRENT curs1;
-- succeeds: re-fetches the same row FETCH NEXT just positioned on
Avoiding FETCH CURRENT after end-of-data
FETCH NEXT curs1;
-- if this hits end-of-data (SQLCODE 100), do NOT attempt
-- FETCH CURRENT afterward — there's no current row
Diagnostic Checks
- Check whether a positioning fetch (
FETCH NEXT/FIRST/etc.) ran successfully before theFETCH CURRENT. - Check the prior fetch's return status, particularly for end-of-data, before retrying with
FETCH CURRENT.
Related Errors / Related Topics
- -400 — "Fetch attempted on unopen cursor." A related fetch-lifecycle error, about the cursor's open/closed state rather than row-positioning state.
- -404 — "The cursor or statement is not available." Another related cursor/statement- lifecycle error covering several broader scenarios.
FETCH CURRENT needs a prior successful positioning fetch — check the previous fetch's status
(especially end-of-data) before attempting to re-fetch the "current" row.