FOR LOOP Statements
The FOR LOOP statement uses FOR statement syntax to specify a variable and a range of values that the variable can take. The loop iterates until the specified limit to these values is reached, or until control is transferred outside the loop, as by the unconditional EXIT statement in the following example:
FOR i IN (1 TO 5) LOOP IF i = 5 THEN EXIT; ELSE CONTINUE; END LOOP;In the FOR LOOP statement, the FOR keyword can follow the EXIT or CONTINUE keyword, but the FOR keyword is not required, as it is in an ordinary FOR statement.
The following example replaces the IF statement with a functionally equivalent conditional EXIT statement:
FOR i IN (1 TO 5) LOOP EXIT WHEN i = 5; END LOOP;