Informix Error -4343: 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.
You can write subscript expressions (integer-valued expressions separated by commas and enclosed in square brackets) following an expression that evaluates to an array. You can specify a substring (two integer expressions in square brackets) following a character expression. However, in this statement, expressions in square brackets follow something that is neither character nor an array. Review the punctuation of the statement and the declaration of the variables in it. Error -4343 with this text is produced by 4GL through Version 4.1.
-4343 Subscripting cannot be applied to the variable variable-name because it is not a character or array variable.
You can write a subscript expression (one, two, or three numbers in square brackets) following the name of an array variable. You can write a substring expression (two numbers in square brackets) following the name of a variable of data type CHAR or VARCHAR. However, variable-name is none of those things. Either it is not the variable you intended, or it is not correctly defined. Error -4343 with this text is produced by 4GL through Version 4.1.
Oninit® Troubleshooting Guidance
Reasons / Common Causes
-4343 covers two related historical variants (both produced by 4GL through Version 4.1) of the same underlying condition — per the official guidance:
-
Applied to an expression: subscript/substring brackets follow an expression that isn't character or array typed.
-
Applied to a variable: subscript/substring brackets follow a variable name that isn't an array variable or a
CHAR/VARCHARvariable. -
Bracketed subscript/substring notation following a non-character, non-array expression or variable, per the official guidance — the direct, only cause.
Solutions / Resolution
- Review the punctuation of the statement and the declaration of the variables involved, per the official guidance.
Examples
Subscripting a non-array, non-character expression
DEFINE qty INTEGER
LET x = (qty + 1)[1,2]
-- -4343: the expression is INTEGER, not CHAR/VARCHAR or ARRAY
Corrected
DEFINE code CHAR(10)
LET x = code[1,2]
Diagnostic Checks
- Check the type of the expression or variable immediately before the bracketed
notation, and confirm it's
CHAR/VARCHARor an array.
Related Errors / Related Topics
- -4159 — "Subscripting cannot be applied to the expression because it is not a character or array reference." The equivalent, currently-active error text for this same condition in later product versions.
- -4344 — "The variable variable-name cannot be used with substrings because it is not a character variable." A related, more specific error about substring notation on a non-character variable.
Bracketed subscript/substring notation follows something that isn't CHAR/VARCHAR or an
array — check its type and the statement's punctuation.