Informix Error -4091: Cannot assign to or refer to an array as a whole. Use indexing to refer to individual elements.
Cause and resolution
Cannot assign to or refer to an array as a whole. Use indexing to refer to individual elements.
The compiler attempted to convert the result of one expression to conform with the type of another expression, and only one of them was an ARRAY. Either both must be ARRAY type, or neither can be.
Oninit® Troubleshooting Guidance
Reasons / Common Causes
-4091 fires when the compiler tries to reconcile two expressions' types and only one of them
is an ARRAY — per the official guidance, either both expressions must be ARRAY type, or
neither can be.
- An expression pairing an
ARRAYwith a non-ARRAYtype, typically from referring to or assigning an array as a whole, per the official guidance — the direct, only cause.
Solutions / Resolution
- Use indexing to refer to individual array elements, per the official guidance, rather than the array as a whole.
Examples
Assigning an array as a whole
DEFINE items ARRAY[10] OF INTEGER
DEFINE total INTEGER
LET total = items
-- -4091: items is an ARRAY, total is not
Corrected
LET total = items[1]
Diagnostic Checks
- Check every assignment or reference involving an
ARRAY, and use indexing to access individual elements instead of the array as a whole.
Related Errors / Related Topics
No closely related error codes are cross-referenced for -4091 in this set yet.
An array is referenced or assigned as a whole, paired with a non-array type — use indexing to access individual elements instead.