Informix Error -404
-404 The cursor or statement is not available.
One of the following four situations occurred:
You used a statement that names a cursor that was released with the FREE statement or that was released during a failed automatic re-prepare. Review the program logic and check that the cursor specified is declared and opened, but not freed, prior to reaching this statement.
If the error occurred on a command that specifies a variable rather than a cursor, the statement was not prepared before you tried to execute it.
The cursor or statement is not available because the connection to the server does not exist or was lost.
The person who created this table has not granted Update privilege to your account name or to the public. The owner of the table or the DBA must grant this privilege before you can update a row in this table.
Oninit® Troubleshooting Guidance
Reasons / Common Causes
-404 is one of the messages that superseded -401 on server versions 5.0 and later (see
-401), and covers four genuinely distinct underlying situations:
- A statement references a cursor that was released via
FREE, or during a failed automatic re-prepare. - A dynamic-SQL command specifying a host variable rather than a cursor, where the statement
was never
PREPAREd before execution was attempted. - The server connection itself doesn't exist or was lost, making any cursor/statement on it unavailable regardless of its own state.
- The table owner never granted
UPDATEprivilege to the user's account or toPUBLIC, preventing row updates via cursor.
Solutions / Resolution
- Review program logic to ensure the cursor is declared and opened, and not freed, before use — for scenario 1, per the official guidance.
- Ensure
PREPAREis executed before attempting to run a dynamically-built statement referenced by a variable — for scenario 2. - Check the connection's actual status and reconnect if it's been lost — for scenario 3, since no amount of cursor-level troubleshooting will help if the underlying connection is gone.
- Have the table owner or a DBA grant
UPDATEprivilege:
— for scenario 4.GRANT UPDATE ON orders TO app_user;
Examples
Scenario 1 — using a cursor after FREE
DECLARE curs1 CURSOR FOR SELECT * FROM orders;
OPEN curs1;
FREE curs1;
FETCH curs1;
-- -404: curs1 was already freed
Scenario 2 — PREPARE missing before dynamic execution
EXECUTE stmt1 USING :param1;
-- -404 if stmt1 was never PREPAREd first
Fix:
PREPARE stmt1 FROM 'UPDATE orders SET status = ? WHERE order_id = ?';
EXECUTE stmt1 USING :new_status, :order_id;
Scenario 4 — missing UPDATE privilege
GRANT UPDATE ON orders TO app_user;
Diagnostic Checks
- Check whether the cursor was freed before the failing statement.
- Check whether
PREPAREwas executed for any dynamically-built statement. - Check the connection's actual status — reconnect if it's been dropped.
- Check
UPDATEprivilege on the target table for the executing user.
Related Errors / Related Topics
- -401 — "Fetch attempted on NULL cursor." The predecessor error this one (along with
-267) replaces on server versions 5.0 and later. - -400 — "Fetch attempted on unopen cursor." A related, narrower cursor-state error — one of
the four scenarios covered by
-404overlaps with this simpler condition. - -315 — "No create index permission." Another privilege-gated operation in the same general
family as scenario 4's missing
UPDATEprivilege.
Four distinct root causes share this one message — identify which of the four scenarios applies
before assuming it's purely a cursor-lifecycle issue; a lost connection or a missing UPDATE
grant are equally likely culprits.