Informix Error -4042: This form of declaration can only appear in the global (module) scope.
Cause and resolution
This form of declaration can only appear in the global (module) scope.
The declaration for identifier::identifier can appear only in the global scope.
Oninit® Troubleshooting Guidance
Reasons / Common Causes
-4042 fires when an identifier::identifier declaration appears outside the global (module)
scope — per the official guidance, this form of declaration can only appear at the global
level.
- An
identifier::identifierdeclaration placed inside a function or other non-global scope, per the official guidance — the direct, only cause.
Solutions / Resolution
- Move the declaration to the global (module) scope.
Examples
A scoped declaration in the wrong place
FUNCTION process()
DEFINE Order::total DECIMAL
-- -4042: this form must be at module scope
END FUNCTION
Corrected
DEFINE Order::total DECIMAL
FUNCTION process()
...
END FUNCTION
Diagnostic Checks
- Check where every
identifier::identifierdeclaration appears, and move any found inside a function to the module's global scope.
Related Errors / Related Topics
No closely related error codes are cross-referenced for -4042 in this set yet.
An identifier::identifier declaration appears outside the global scope — move it to module
level.