Informix Error -697
-697 STEP expression evaluated to ZERO.
The STEP expression of a FOR statement evaluated to zero.
Example of error:
LET e = -1; FOR i = 10 TO 20 STEP e+1; -- error ... END FOR
Correction: Change the STEP expression so that it evaluates to a nonzero value.
Oninit® Troubleshooting Guidance
Reasons / Common Causes
-697 fires when a FOR statement's STEP expression evaluates to zero — per the official
guidance's example, LET e = -1; FOR i = 10 TO 20 STEP e+1 computes a step of -1 + 1 = 0,
which would never advance the loop variable at all.
- A
STEPexpression built from variables whose combined value happens to be zero, per the official guidance's example — not obviously zero from the literal syntax, only after evaluation. - A
STEPexpression that's correct in most cases but degenerates to zero for certain input values, surfacing only under specific runtime conditions rather than every time the routine runs.
Solutions / Resolution
- Change the
STEPexpression so it evaluates to a nonzero value, per the official guidance's documented correction. - If the
STEPexpression is built from variables, trace their values at the point of failure to understand why the combination produced zero this time. - Add a guard before the
FORstatement if the step is computed from data that could legitimately produce zero, handling that case explicitly rather than letting it reach the loop.
Examples
The disallowed zero step
DEFINE e INT;
LET e = -1;
FOR i = 10 TO 20 STEP e + 1
...
END FOR;
-- -697: e + 1 evaluates to 0
Corrected
DEFINE e INT;
LET e = -1;
FOR i = 10 TO 20 STEP e + 2
...
END FOR;
Diagnostic Checks
- Evaluate the
STEPexpression's actual computed value, not just its literal syntax, since a zero result can come from a combination of variables that isn't obviously zero at a glance.
Related Errors / Related Topics
- -683 — "Specified STEP expression will not traverse RANGE." A related
FOR-loopSTEPerror, about the step's sign being wrong for the range's direction, rather than the step being exactly zero.
A zero step is a distinct failure from -683's wrong-direction step — check the expression's actual evaluated value, not just its literal form.