Kbase P182203: DO WHILE loop terminates unexpectedly upon ERROR
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  08/02/2011 |
|
Status: Unverified
SYMPTOM(s):
DO WHILE loop terminates unexpectedly upon ERROR
DO WHILE loop exits unexpectedly after ERROR is raised
The following example code demonstrates loop termination upon the first error, ignoring the error handling statements such as ON ERROR UNDO, NEXT
DEFINE TEMP-TABLE ttMetricValue NO-UNDO
FIELD deMetricDecimalValue AS DECIMAL INITIAL ?
INDEX ByMetricDecimalValue IS PRIMARY UNIQUE deMetricDecimalValue.
DEFINE VARIABLE i AS INTEGER NO-UNDO INITIAL 1.
DO WHILE i <= 5 ON ERROR UNDO, NEXT:
i = i + 1.
CREATE ttMetricValue.
ttMetricValue.deMetricDecimalValue = 1.
CATCH e AS Progress.Lang.Error:
MESSAGE "error" VIEW-AS ALERT-BOX.
DELETE ttMetricValue.
END CATCH.
END.
FACT(s) (Environment):
All Supported Operating Systems
Progress 7.x
Progress 8.x
Progress 9.x
OpenEdge 10.x
CAUSE:
This is expected behavior. When the ABL encounters an error in a DO WHILE loop there is no way to be certain that the code which increments the counter is before or after the point where the error condition occurs, and therefore whether it will ever be reached. In an effort to prevent an infinite loop occurring, the ABL exits the loop.
FIX:
Use a loop that increments the counter in the loop statement rather than a DO WHILE or REPEAT loop whose counter is incremented in the body of the block.