Informix Error -4071: Cannot assign to constant "name".
Cause and resolution
Cannot assign to constant "name".
This statement would assign a new value to name, but name was declared (in this scope) with a CONSTANT statement. Constants do not have memory locations and cannot be assigned new values. Check that name is the identifier you intended to use. Then review its declaration. Possibly you want to assign into a module-level variable name, but it has been declared as a local constant or a member constant that takes precedence in this context.
Oninit® Troubleshooting Guidance
Reasons / Common Causes
-4071 fires when a statement tries to assign a new value to a name declared with CONSTANT —
per the official guidance, constants have no memory location and can't be assigned. The
official guidance also flags a common variant: intending to assign a module-level variable,
but a local or member constant of the same name takes precedence in that scope.
- The target name was declared
CONSTANTin this scope, per the official guidance — the direct, only cause. - A same-named local or member constant is shadowing the intended module-level variable, per the official guidance — a related, commonly-confused variant.
Solutions / Resolution
- Check that
nameis the identifier intended, per the official guidance. - Review its declaration, per the official guidance — if a module-level variable was intended, rename the shadowing constant or qualify the reference.
Examples
Assigning to a constant
CONSTANT max_retries = 3
LET max_retries = 5
-- -4071: max_retries is a CONSTANT, not assignable
Corrected
DEFINE max_retries INTEGER
LET max_retries = 5
Diagnostic Checks
- Check whether the target name is declared
CONSTANTin the current scope, and confirm it isn't shadowing an intended module-level variable of the same name.
Related Errors / Related Topics
No closely related error codes are cross-referenced for -4071 in this set yet.
An assignment targets a name declared CONSTANT — constants can't be assigned; check for a
shadowed module-level variable if one was intended.