Informix Error -658
-658 Variables declared as GLOBAL require a default value.
A global variable was not given a default value. Global variables require a default value.
Example of error:
DEFINE GLOBAL glob INT; -- error
Correction:
DEFINE GLOBAL glob INT DEFAULT 10;
Oninit® Troubleshooting Guidance
Reasons / Common Causes
-658 fires when a DEFINE GLOBAL variable declaration has no DEFAULT clause — per the official
guidance, unlike local variables (which per -652 can't have a default at all), global variables
specifically require one.
DEFINE GLOBAL var typewith noDEFAULTclause, per the official guidance's own example — the direct, only cause.- A local-variable declaration pattern (no default) reused for a global variable, without realizing the requirement runs the opposite direction for globals.
Solutions / Resolution
- Add a
DEFAULTclause to the global variable's declaration, per the official guidance's documented correction:
instead ofDEFINE GLOBAL glob INT DEFAULT 10;DEFINE GLOBAL glob INT;. - Choose a default value appropriate to the global variable's intended initial state, since it will be used until explicitly reassigned elsewhere.
Examples
The disallowed attempt
DEFINE GLOBAL glob INT;
-- -658: global variables require a DEFAULT value
Corrected
DEFINE GLOBAL glob INT DEFAULT 10;
Diagnostic Checks
- Scan
DEFINE GLOBALstatements for a missingDEFAULTclause, and add one appropriate to the variable's intended initial value.
Related Errors / Related Topics
- -652 — "Local variables do not allow default values." The opposite requirement, for local variables — they can never have a default, while globals always must.
- -653 — "Variables declared as LIKE cannot be global." Another global-variable declaration
restriction, about
LIKErather thanDEFAULT.
The opposite rule from -652 — global variables always require a DEFAULT, where local variables
never allow one.