Informix Error -4159: Subscripting cannot be applied to the expression because it is not a character or array reference.
Cause and resolution
Subscripting cannot be applied to the expression because it is not a character or array reference.
The expression cannot be qualified by a subscript because the expression is neither an ARRAY nor CHAR() type.
Oninit® Troubleshooting Guidance
Reasons / Common Causes
-4159 fires when a subscript is applied to an expression that isn't an ARRAY or CHAR()
type — per the official guidance, subscripting is only valid on those two kinds of
expressions.
- A subscript applied to a non-
ARRAY, non-CHAR()expression, per the official guidance — the direct, only cause.
Solutions / Resolution
- Remove the subscript, or apply it to a genuinely
ARRAY/CHAR()expression instead.
Examples
Subscripting a non-array, non-character value
DEFINE qty INTEGER
LET x = qty[1,2]
-- -4159: qty is INTEGER, not ARRAY or CHAR()
Corrected
DEFINE code CHAR(10)
LET x = code[1,2]
Diagnostic Checks
- Check the type of every subscripted expression, and confirm it's
ARRAYorCHAR().
Related Errors / Related Topics
- -4074 — "No more than two substring index expressions are allowed." A related subscripting error, about the substring qualifier's own bounds rather than the base expression's type.
A subscript is applied to an expression that isn't ARRAY or CHAR() — check the base
expression's type.