Informix Error -719
-719 Loop variable variable-name cannot be declared GLOBAL.
A global variable cannot be used as a loop variable. Redefine the variable to be local to the loop, or use another (local) variable as the loop variable.
Oninit® Troubleshooting Guidance
Reasons / Common Causes
-719 fires when a FOR/FOREACH loop's variable is declared GLOBAL — per the official
guidance, a global variable can't serve as a loop variable; loop variables must be local.
- A global variable used directly as a
FOR/FOREACHloop variable — the direct, only cause. - A variable declared
GLOBALfor use elsewhere in the application, then reused as a loop variable in a routine, without realizing the two roles are incompatible.
Solutions / Resolution
- Redefine the variable to be local to the loop, per the official guidance's documented correction, if it doesn't genuinely need to be global.
- Or use a different (local) variable as the loop variable, per the official guidance, keeping the global variable for whatever purpose actually required it to be global.
Examples
The disallowed attempt
DEFINE GLOBAL i INT DEFAULT 0;
FOR i = 1 TO 10
...
END FOR;
-- -719: i is declared GLOBAL
Corrected — a local loop variable
DEFINE i INT;
FOR i = 1 TO 10
...
END FOR;
Diagnostic Checks
- Check whether the
FOR/FOREACHloop's variable was declared withGLOBAL, and switch to a local variable if so.
Related Errors / Related Topics
- -660 — "Loop variable variable-name cannot be modified." A related
FOR-loop restriction, about modifying the loop variable inside the loop rather than its declaration scope. - -662 — "Loop variable variable-name specified more than once." A related loop-variable
restriction, about reusing a name in a
FOREACHclause. - -658 — "Variables declared as GLOBAL require a default value." A related global-variable
declaration rule, unrelated to loop-variable eligibility but part of the same
GLOBALdeclaration family.
Loop variables must be local — redeclare without GLOBAL, or use a separate local variable for
the loop.