Informix Error -652
-652 Local variables do not allow default values.
An attempt was made to define a local variable with a default value. Only global variables and parameters can have default values.
An example of the error follows:
DEFINE var INT DEFAULT 10; -- error
The correction is as follows:
DEFINE var INT; LET var = 10;
Oninit® Troubleshooting Guidance
Reasons / Common Causes
-652 fires when a local variable's DEFINE includes a DEFAULT clause — per the official
guidance, only global variables and routine parameters can have default values; local variables
can't.
DEFINE var type DEFAULT valueused for a local variable, per the official guidance — the direct, only cause.- A pattern carried over from parameter or global-variable definitions, which do support
DEFAULT, applied to an ordinary local variable where it isn't supported.
Solutions / Resolution
- Split the definition into a plain
DEFINEfollowed by aLETassignment, per the official guidance's documented correction:
instead ofDEFINE var INT; LET var = 10;DEFINE var INT DEFAULT 10;. - If a genuine default-value pattern is needed, use a global variable or a routine
parameter instead, per the official guidance, since those are the two contexts that support
DEFAULTdirectly.
Examples
The disallowed attempt
CREATE PROCEDURE process_order()
DEFINE v_status INT DEFAULT 10;
...
END PROCEDURE;
-- -652: local variables don't allow DEFAULT
Corrected
CREATE PROCEDURE process_order()
DEFINE v_status INT;
LET v_status = 10;
...
END PROCEDURE;
Diagnostic Checks
- Scan
DEFINEstatements for a local variable combined withDEFAULT, and split each one into a plainDEFINEplus a separateLETassignment.
Related Errors / Related Topics
- -591 — "Invalid default value for column/variable column-name/variable-name." A related
DEFAULT-clause error, about the value's type/length rather than whereDEFAULTis allowed at all. - -653 — "Variables declared as LIKE cannot be global." Another SPL variable-declaration
restriction, about
LIKEand scope rather thanDEFAULTand scope.
Local variables never take DEFAULT — split into a plain DEFINE plus a LET assignment
instead.