Informix Error -402
-402 Address of a host variable is NULL.
Review the way the program constructs the sqlda and related data structures; somehow it is setting up a null pointer. The error might be caused by using a row or collection host variable without having executed the necessary ALLOCATE statement.
If the program is in IBM Informix 4GL or another language in which the sqlda is not constructed directly by the program, or if this statement refers only to host variables by name, this error should not occur. If the error recurs, note all circumstances and contact IBM Informix Technical Support.
Oninit® Troubleshooting Guidance
Reasons / Common Causes
-402 is an embedded-SQL/ESQL-C client-programming error: the program's sqlda (SQL Descriptor
Area) or a related data structure contains a null pointer where a valid host-variable address was
expected. Per the official guidance, this shouldn't normally occur in higher-level environments
like IBM Informix 4GL, where the sqlda is constructed automatically — it's specifically a risk
in lower-level embedded SQL/ESQL-C code that manages these structures manually.
- A row or collection host variable used without first executing the required
ALLOCATEstatement — the most common specific cause called out by the official guidance. - Manual
sqldaconstruction with a bug leaving a host-variable pointer field unset (null) where a real address was expected. - A host variable that went out of scope or was freed before the statement using it executed, leaving a dangling/null reference.
Solutions / Resolution
- Ensure
ALLOCATEis executed for row/collection host variables before they're used, per the official guidance — this is the most common concrete fix. - Review manual
sqldaconstruction code for any host-variable pointer field left unset/null. - Confirm host variables remain in scope and allocated for the full duration they're referenced by a SQL statement.
- If using a higher-level language (4GL and similar) where this shouldn't normally occur, treat its appearance as a signal of a genuine bug in the runtime or generated code, rather than an application-level input mistake.
Examples
Allocating a row host variable before use
/* Ensure ALLOCATE has run before using a row-type host variable */
EXEC SQL ALLOCATE ROW :my_row_var;
EXEC SQL SELECT * INTO :my_row_var FROM orders WHERE order_id = 1001;
The disallowed unallocated usage
/* my_row_var declared but never ALLOCATEd */
EXEC SQL SELECT * INTO :my_row_var FROM orders WHERE order_id = 1001;
/* -402: my_row_var's underlying structure has a null address */
Diagnostic Checks
- Check whether
ALLOCATEwas executed for any row/collection host variable involved in the failing statement. - Review manually constructed
sqldastructures for unset pointer fields. - Confirm the host variable's scope and lifetime cover the statement's execution.
Related Errors / Related Topics
- -392 — "System error - unexpected null pointer encountered." A related null-pointer-class error, though server-internal rather than a client-side embedded-SQL programming mistake.
- -401 — "Fetch attempted on NULL cursor." Another related invalid-structure error in the embedded-SQL/cursor-handling family.
This is specifically an embedded-SQL/ESQL-C client-programming concern — ALLOCATE for
row/collection host variables is the most common fix, and it shouldn't normally surface at all in
higher-level environments like 4GL.