Informix Error -417
-417 FLUSH can only be used on an insert cursor.
This FLUSH statement refers to a cursor that is associated with a SELECT statement, not an INSERT statement. FLUSH is only appropriate with insert cursors. Review the program to ensure that the correct cursor has been named.
Oninit® Troubleshooting Guidance
Reasons / Common Causes
-417 fires when FLUSH is issued against a cursor declared over a SELECT statement — FLUSH
exists specifically to force buffered rows queued via PUT on an insert cursor out to the
server, so it has no meaning for a select cursor.
- A
FLUSHstatement referencing a select cursor — the direct, only cause, usually from copy-pasted insert-cursor code applied to the wrong cursor variable/name. - Confusing which cursor identifier corresponds to which declared statement, in code managing multiple cursors of different kinds.
Solutions / Resolution
- Verify the correct cursor is being referenced, per the official guidance — confirm it was
actually declared over an
INSERTstatement, not aSELECT. - Remove the
FLUSHcall entirely if the cursor is a select cursor — there's nothing for it to flush, since select cursors don't buffer outgoing rows the way insert cursors do.
Examples
FLUSH mistakenly applied to a select cursor
DECLARE curs1 CURSOR FOR SELECT * FROM orders;
OPEN curs1;
FLUSH curs1;
-- -417: curs1 is a SELECT cursor, not an INSERT cursor
FLUSH correctly applied to an insert cursor
DECLARE curs2 CURSOR FOR INSERT INTO orders (order_id, customer_id) VALUES (?, ?);
OPEN curs2;
PUT curs2 FROM :ord_id, :cust_id;
-- ... more PUTs ...
FLUSH curs2;
-- forces buffered rows out to the server
Diagnostic Checks
- Check the
DECLAREstatement for the cursor named in theFLUSHcall and confirm it's anINSERT, not aSELECT. - Review variable naming if multiple cursors are in play, to rule out a mix-up between them.
Related Errors / Related Topics
- -416 — "USING option with open statement is invalid for insert cursor." A related insert- cursor-specific syntax restriction, in the opposite direction (a select-cursor clause mistakenly applied to an insert cursor).
- -363 — "CURSOR not on SELECT statement." Another cursor-type restriction, in a different
context (declaring a cursor over a non-
SELECTstatement generally).
FLUSH only makes sense for insert cursors, which buffer outgoing rows via PUT — confirm the
cursor's declared statement type before applying it.