Informix Error -4340: The variable variable-name is too complex a type to be used in an expression.
Cause and resolution
The variable variable-name is too complex a type to be used in an expression.
By "too complex," NewEra means "has too many component parts." In an expression, only simple variables (those that have a single component) can be used. If the variable indicated is an array, you must provide a subscript to select just one element. If it is a record or object, you must choose just one of its components. NewEra programs return this error.
Oninit® Troubleshooting Guidance
Reasons / Common Causes
-4340 fires when a variable with multiple components is used directly in an expression — per the official guidance, "too complex" means "has too many component parts"; an array needs a subscript to select one element, and a record or object needs one of its components chosen. NewEra programs return this error.
- An array used without a subscript in an expression, per the official guidance — the first named case.
- A record or object used without selecting a single component in an expression, per the official guidance — the second named case.
Solutions / Resolution
- Provide a subscript to select one array element, per the official guidance.
- Choose one component of the record or object, per the official guidance.
Examples
A record used directly in an expression
DEFINE rec RECORD
qty INTEGER,
price DECIMAL
END RECORD
LET x = rec + 1
-- -4340: rec has multiple components; expressions need a single component
Corrected
LET x = rec.qty + 1
Diagnostic Checks
- Check the flagged variable's type, and provide a subscript (array) or select a single component (record/object) as required.
Related Errors / Related Topics
- -4334 — "The variable variable-name in its current form is too complex to be used in this statement." A closely related error covering the same condition in the classic 4GL context.
A record, object, or array is used directly in an expression — provide a subscript or select a single component.