Loop Statements
The LOOP construct allows you to repeatedly execute a sequence of statements. There are three kinds of loops: simple, WHILE, and FOR; there are two variants on the FOR loop: the numeric FOR loop and the CURSOR FOR loop.
All loops can have a label or contain an EXIT statement.
Loops can be optionally labeled to improve readability and execution control. The label must appear immediately in front of the statement that initiates the loop.
The EXIT statement is used to break out of the loop and pass control to the statement following the END LOOP. The syntax for the EXIT statement is:
EXIT [WHEN Boolean_condition];If you do not include a WHEN clause in the EXIT statement, it will terminate the loop unconditionally. Otherwise, the loop terminates only if Boolean_condition evaluates to TRUE. The EXIT statement is optional and can appear anywhere in the loop.