Informix Error -4344: The variable variable-name cannot be used with substrings because it is not a character variable.
Cause and resolution
The variable variable-name cannot be used with substrings because it is not a character variable.
This statement contains what appears to be a substring expression (two numbers in square brackets) following the identifier shown. However, that variable is not of data type CHAR or VARCHAR. If you intended this variable as a substring, then you either named the wrong variable, or the variable is not correctly defined. If you meant this as an array subscript, the same is true.
Oninit® Troubleshooting Guidance
Reasons / Common Causes
-4344 fires when a substring expression (two numbers in square brackets) follows a variable
that isn't CHAR/VARCHAR — per the official guidance, if the substring was intended, either
the wrong variable was named or it isn't correctly defined; the same applies if an array
subscript was intended instead.
- A substring expression applied to a variable that isn't
CHAR/VARCHAR, per the official guidance — the direct, only cause.
Solutions / Resolution
- Check whether the correct variable was named, per the official guidance.
- Check that the variable is correctly defined as
CHAR/VARCHARif a substring was genuinely intended, per the official guidance.
Examples
A substring on a non-character variable
DEFINE qty INTEGER
LET x = qty[1,2]
-- -4344: qty is INTEGER, not CHAR/VARCHAR
Corrected
DEFINE code CHAR(10)
LET x = code[1,2]
Diagnostic Checks
- Check the declared type of the variable used with substring notation, and confirm it's
CHAR/VARCHAR.
Related Errors / Related Topics
- -4343 — "Subscripting cannot be applied to the expression because it is not a character or array reference." A related, more general error covering both expressions and variables, including array subscripting.
- -4075 — "Simple string expressions must have type CHAR or VARCHAR." A related string-type requirement, about simple string expressions generally rather than substring notation specifically.
A substring expression is applied to a non-CHAR/VARCHAR variable — check its declared type.