Informix Error -22620: Host object host variable not declared.
Cause and resolution
Host object host variable not declared.
This message indicates an IBM Informix ESQL/FORTRAN preprocessor error. An SQL statement contains a host variable that has not been declared. Host variables are declared in the same way as other FORTRAN variables except that the declaration must be contained in a declaration block between a pair of EXEC SQL BEGIN DECLARE SECTION and EXEC SQL END DECLARE SECTION statements. You cannot use the SQL data types to declare host variables. You must specify a FORTRAN data type or one of the IBM Informix ESQL/FORTRAN data types when you declare a host variable. The data type of the host variable should reflect the data type of the database column to which it corresponds.
Oninit® Troubleshooting Guidance
Reasons / Common Causes
-22620 fires when an SQL statement references a host variable that hasn't been
declared — per the official guidance, host variables must be declared between a pair of
EXEC SQL BEGIN DECLARE SECTION/EXEC SQL END DECLARE SECTION statements, using a
FORTRAN or ESQL/FORTRAN data type (not an SQL data type), matching the corresponding
database column's data type.
- A host variable referenced in SQL without being declared in a declare section, per the official guidance — the direct, only cause.
Solutions / Resolution
- Declare the host variable between
EXEC SQL BEGIN DECLARE SECTIONandEXEC SQL END DECLARE SECTION, per the official guidance, using a FORTRAN or ESQL/FORTRAN data type matching the corresponding column.
Examples
N/A
No specific triggering statement is documented beyond referencing an undeclared host variable.
Diagnostic Checks
- Check the declare section for the flagged host variable's declaration, and add it if missing.
Related Errors / Related Topics
- -22628 — "Record component component-name not declared." A related declaration error, on a record's component rather than the host variable itself.
A host variable was referenced in SQL without being declared in a declare section — add its declaration.