Informix Error -4346
-4346 Subscripts can contain only INTEGER or SMALLINT expressions.
Array subscripts are integer values, and only integer variables can be used to form them. This statement contains a subscript in which a FLOAT, CHAR or some other type of variable is used. No automatic conversion of data types is performed in a subscript expression. Review the subscript expressions in the statement; perhaps you simply entered the wrong variable name. If not, you will have to revise the program to store array subscripts in integer variables only (you might expect that a DECIMAL value with a scale factor of zero would be permitted also, but this is not the case.)
Oninit® Troubleshooting Guidance
Reasons / Common Causes
-4346 fires when an array subscript expression uses a non-integer type such as FLOAT or
CHAR — per the official guidance, no automatic conversion happens in a subscript expression;
notably, even a DECIMAL with scale zero isn't accepted.
- A subscript expression using a
FLOAT,CHAR, or other non-integer type, per the official guidance — the direct, only cause.
Solutions / Resolution
- Review the subscript expression for the wrong variable name, per the official guidance.
- Otherwise, store array subscripts only in
INTEGER/SMALLINTvariables, per the official guidance — a zero-scaleDECIMALis explicitly not accepted either.
Examples
A DECIMAL used as a subscript
DEFINE ix DECIMAL(5,0)
DEFINE items ARRAY[10] OF INTEGER
LET x = items[ix]
-- -4346: DECIMAL is not accepted for subscripts, even with scale 0
Corrected
DEFINE ix INTEGER
LET x = items[ix]
Diagnostic Checks
- Check the declared type of every array subscript variable, and confirm it's
INTEGER/SMALLINT, notFLOAT,CHAR, orDECIMAL(even with scale 0).
Related Errors / Related Topics
- -4327 — "The variable variable-name is not of type INTEGER or SMALLINT. It cannot be
used as a loop index." A related integer-type requirement, about
FORloop indices rather than array subscripts. - -4331 — "Only variables of type INTEGER or SMALLINT may be used to index display fields." A related integer-type requirement, about screen-array subscripts specifically.
An array subscript uses a non-integer type — use INTEGER/SMALLINT only.