Informix Error -412
-412 Command pointer is NULL.
This statement (probably an EXECUTE or DECLARE) refers to a dynamic SQL statement that has never been prepared or that has been freed. Review the program logic to ensure that the statement has been prepared, the PREPARE did not return an error code, and the FREE statement has not been used to release the statement before this point.
Oninit® Troubleshooting Guidance
Reasons / Common Causes
-412 is a close sibling of -410/-404: an EXECUTE or DECLARE references a dynamic SQL
statement whose internal command pointer is null — either because it was never successfully
prepared, or because it was prepared and then already freed with FREE.
EXECUTE/DECLAREreferencing a statement identifier that was neverPREPAREd.PREPAREwas attempted but failed, leaving the statement identifier without a valid command pointer, and the failure wasn't checked before proceeding.- The statement was already
FREEd, andEXECUTE/DECLAREwas attempted against it afterward without re-preparing.
Solutions / Resolution
- Review program logic to verify the statement was successfully prepared (check
PREPARE's return code), per the official guidance. - Confirm
FREEhasn't been called prematurely on the statement before the failingEXECUTE/DECLARE. - Re-prepare the statement if it needs to be used again after being freed — a freed
statement identifier isn't reusable without another
PREPARE.
Examples
Using a statement after it was freed
PREPARE stmt1 FROM 'SELECT * FROM orders WHERE order_id = ?';
DECLARE curs1 CURSOR FOR stmt1;
FREE stmt1;
OPEN curs1;
-- -412: stmt1's command pointer is null after FREE
Fix — don't free the statement until done with any cursors declared against it, or re-prepare before reuse:
PREPARE stmt1 FROM 'SELECT * FROM orders WHERE order_id = ?';
DECLARE curs1 CURSOR FOR stmt1;
OPEN curs1;
-- ... use the cursor ...
CLOSE curs1;
FREE stmt1;
Diagnostic Checks
- Check whether
PREPAREsucceeded for the statement identifier in question. - Check whether
FREEwas called on the statement before the failingEXECUTE/DECLARE.
Related Errors / Related Topics
- -410 — "Prepare statement failed or was not executed." The closest sibling — the same general class of unprepared/failed-preparation error.
- -404 — "The cursor or statement is not available." A related, broader cursor/statement- lifecycle error covering several similar scenarios, including a freed statement.
Check whether the statement was successfully prepared and hasn't since been freed — this is the
same underlying discipline as -410, applied to DECLARE as well as EXECUTE.