Informix Error -22285: Incorrect dimension on table variable variable-name.
Cause and resolution
Incorrect dimension on table variable variable-name.
An entry in a multidimensional array is illegally accessed. Indexes for multidimensional arrays must be specified when used. For example, suppose a host variable is declared in ESQL/COBOL as follows:
01 VARA X(10) OCCURS 3 TIMES.
It will return an error if it is used in an SQL statement as follows because you must specify the index into which you want to insert (that is, VARA(1)):
INSERT INTO TAB VALUES ($VARA)
Oninit® Troubleshooting Guidance
Reasons / Common Causes
-22285 fires when a multidimensional array's entry is accessed without specifying the
needed index — per the official guidance; for example, a host variable declared
01 VARA X(10) OCCURS 3 TIMES. needs its index specified (VARA(1)) when used in an SQL
statement, and using it unindexed (e.g. INSERT INTO TAB VALUES ($VARA)) triggers this
error.
- A multidimensional array host variable used in an SQL statement without its required index, per the official guidance — the direct, only cause.
Solutions / Resolution
- Specify the index into which to insert/select, per the official guidance, e.g.
$VARA(1)rather than$VARA.
Examples
An unindexed multidimensional array reference
01 VARA X(10) OCCURS 3 TIMES.
...
EXEC SQL INSERT INTO TAB VALUES ($VARA);
-- -22285: VARA needs an index, e.g. VARA(1)
Corrected
EXEC SQL INSERT INTO TAB VALUES ($VARA(1));
Diagnostic Checks
- Check the flagged array variable's SQL-statement usage for a missing index, and add the required subscript.
Related Errors / Related Topics
No closely related error codes are cross-referenced for -22285 in this set yet.
A multidimensional array host variable was used in SQL without its required index — add
the subscript, e.g. VARA(1).