WHILE LOOP Statements

To create a WHILE LOOP statement, loop, you can immediately follow a WHILE condition specification with a LOOP statement. The resulting loop terminates after the condition becomes false, or when some other statement transfers program control from the loop. In the following WHILE LOOP statement, the condition specifies that the loop terminates after the loop variable i has been incremented to the value of 6:
WHILE (i < 6) LOOP
   LET i = i + 1;
   IF i = 5 THEN EXIT;
   ELSE
   CONTINUE;
   END IF
END LOOP;

As in the FOR LOOP statement, the EXIT and CONTINUE keywords do not need to specify the type of loop statement, but the example would not be affected if EXIT WHILE and CONTINUE WHILE replaced the EXIT and CONTINUE keywords. The END LOOP keywords are required, however, because HCL OneDB™ treats the WHILE LOOP (and FOR LOOP) statements as LOOP statements, despite their initial FOR and WHILE specifications.