Informix Error -1814: Need to allocate collection or row variable before using it.
Cause and resolution
Need to allocate collection or row variable before using it.
The application needs to call ALLOCATE COLLECTION or ALLOCATE ROW before it uses a host variable of type collection or of type row in an SQL statement.
Oninit® Troubleshooting Guidance
Reasons / Common Causes
-1814 fires when a host variable of type collection or row is used in an SQL statement without
first being allocated — per the official guidance, ALLOCATE COLLECTION or ALLOCATE ROW must
be called before such a variable is used.
- A collection/row host variable used without a preceding
ALLOCATE COLLECTION/ALLOCATE ROW, per the official guidance — the direct, only cause.
Solutions / Resolution
- Call
ALLOCATE COLLECTIONorALLOCATE ROWbefore using the variable, per the official guidance, matching the variable's actual type.
Examples
A collection variable used without allocation
collection *items;
EXEC SQL SELECT item_list INTO :items FROM orders WHERE order_id = 1;
-- -1814: items was never allocated
Corrected
collection *items;
EXEC SQL ALLOCATE COLLECTION :items;
EXEC SQL SELECT item_list INTO :items FROM orders WHERE order_id = 1;
Diagnostic Checks
- Check whether
ALLOCATE COLLECTION/ALLOCATE ROWwas called before the variable's use in the failing statement.
Related Errors / Related Topics
- -1815 — "No type information for collection or row is available." A related complex-type error, about a missing type declaration rather than a missing allocation.
A collection/row host variable was used without being allocated first — call ALLOCATE COLLECTION/ALLOCATE ROW before using it.