Informix Error -422
-422 Flush attempted on unopen cursor.
This FLUSH statement names a cursor that has never been opened or has been closed. Review the program logic to ensure that it will open the cursor before this point and not accidentally close it. An insert cursor is automatically closed by a COMMIT WORK or ROLLBACK WORK.
Oninit® Troubleshooting Guidance
Reasons / Common Causes
-422 is the FLUSH-specific instance of the same open/close-lifecycle issue as -413/-400: a
FLUSH was issued against an insert cursor that isn't currently open — never opened, already
closed, or implicitly closed by COMMIT WORK/ROLLBACK WORK.
- A
FLUSHissued before the correspondingOPENon the insert cursor. - A
FLUSHissued afterCLOSE, without reopening. COMMIT WORK/ROLLBACK WORKimplicitly closing the insert cursor, since these automatically close insert cursors — aFLUSHafter that point fails.
Solutions / Resolution
- Review program logic to confirm the cursor is opened before the
FLUSH, per the official guidance. - Reopen the cursor after any
COMMIT WORK/ROLLBACK WORKif furtherPUT/FLUSHoperations through it are needed. - Check for a premature
CLOSEif the cursor is closing earlier than expected.
Examples
Flushing after an implicit close
DECLARE curs1 CURSOR FOR INSERT INTO orders (order_id, customer_id) VALUES (?, ?);
OPEN curs1;
PUT curs1 FROM :ord_id, :cust_id;
COMMIT WORK;
FLUSH curs1;
-- -422: COMMIT WORK closed curs1 automatically
Fix — reopen before flushing:
OPEN curs1;
PUT curs1 FROM :ord_id, :cust_id;
FLUSH curs1;
COMMIT WORK;
Diagnostic Checks
- Confirm the cursor was opened before the failing
FLUSH. - Check for an intervening
CLOSE,COMMIT WORK, orROLLBACK WORK.
Related Errors / Related Topics
- -413 — "Insert attempted on unopen cursor." The closely related sibling — the same
underlying open/close lifecycle issue, applied to
PUTinstead ofFLUSH. - -417 — "FLUSH can only be used on an insert cursor." Another
FLUSH-specific restriction, about cursor type rather than open/close state.
COMMIT WORK/ROLLBACK WORK automatically close insert cursors — flush (and reopen) before
committing if more inserts are still pending.