Informix Error -4160: This expression cannot be used as the target of an assignment statement.
Cause and resolution
This expression cannot be used as the target of an assignment statement.
An illegal assignment was detected. For example, you declared abc to be a constant, but here you attempted to assign a value to it. Some statements that involve assignment: LET, SELECT...INTO, OPEN CURSOR...INTO, FETCH INTO, FOREACH...INTO, FOR iterator (the iterator is assigned values), INITIALIZE, and LOCATE. Only NewEra returns this error.
Oninit® Troubleshooting Guidance
Reasons / Common Causes
-4160 fires when an illegal assignment target is used — per the official guidance, a common
example is a name declared CONSTANT used as an assignment target; the official guidance also
lists the statements that involve assignment: LET, SELECT...INTO, OPEN CURSOR...INTO,
FETCH INTO, FOREACH...INTO, FOR (the iterator variable), INITIALIZE, and LOCATE. Only
NewEra returns this error.
- An assignment (via any of the listed statement forms) targeting an expression that isn't a valid assignment target, per the official guidance — the direct, only cause.
Solutions / Resolution
- Assign to a genuine variable instead, checking whether the target was accidentally
declared
CONSTANTor is otherwise non-assignable.
Examples
Assigning to a constant via SELECT INTO
CONSTANT max_id = 9999
...
SELECT MAX(order_id) INTO max_id FROM orders
-- -4160: max_id is CONSTANT, not assignable
Corrected
DEFINE max_id INTEGER
SELECT MAX(order_id) INTO max_id FROM orders
Diagnostic Checks
- Check the target of every assignment-style statement (
LET,SELECT...INTO,OPEN CURSOR...INTO,FETCH INTO,FOREACH...INTO,FOR,INITIALIZE,LOCATE), and confirm it's a genuine, non-constant variable.
Related Errors / Related Topics
- -4071 — "Cannot assign to constant "name"." A closely related error, covering the same
constant-assignment restriction specifically for
LET-style assignment.
An assignment statement targets something that isn't a valid assignment target (often a constant) — assign to a genuine variable instead.