Informix Error -683
-683 Specified STEP expression will not traverse RANGE.
The evaluated value of the STEP expression in the FOR statement will lead to an infinite loop.
Example of error:
FOR i = 10 TO 20 STEP -1; -- error ... END FOR
Correction: Correct either the range or the step expressions so that the incremented values are within the range.
Oninit® Troubleshooting Guidance
Reasons / Common Causes
-683 fires when a FOR statement's STEP value, combined with its TO range, would never
actually reach the end of the range — per the official guidance's example, FOR i = 10 TO 20 STEP -1 decrements from 10 and can never reach 20, producing what would otherwise be an infinite
loop.
- A negative
STEPused with an ascending range (start < end), per the official guidance's example — the step moves the wrong direction to ever reach the endpoint. - A positive
STEPused with a descending range (start > end), the mirror-image mistake. - A
STEPsign that was correct when the range's bounds were literals, but became wrong after the range's start/end were changed to variables whose values flipped the intended direction.
Solutions / Resolution
- Adjust the range or step expression so incremented/decremented values stay within the
intended range, per the official guidance — match the
STEPsign to the range's direction. - For an ascending range (
startless thanend), use a positiveSTEP. - For a descending range (
startgreater thanend), use a negativeSTEP. - If the range's bounds come from variables, confirm their relative order at runtime, not
just at the time the loop was written, since the correct
STEPsign depends on their actual values each time the loop runs.
Examples
The disallowed combination
FOR i = 10 TO 20 STEP -1
...
END FOR;
-- -683: decrementing from 10 will never reach 20
Corrected
FOR i = 10 TO 20 STEP 1
...
END FOR;
A descending range, correctly stepped
FOR i = 20 TO 10 STEP -1
...
END FOR;
Diagnostic Checks
- Compare the range's direction (
startvs.end) against theSTEPvalue's sign for everyFORstatement, especially when either bound comes from a variable rather than a literal.
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. - -666 — "Variable variable-name must be declared INTEGER or SMALLINT." A related
FOR-loop restriction, about the loop variable's declared type.
Match the STEP sign to the range's actual direction — positive for ascending, negative for
descending — checked against the bounds' runtime values, not just how the loop was originally
written.