PL/SQL allows you to branch and create loops in a fairly familiar way.
An IF statement looks like:
IF
The ELSE part is optional. If you want a multiway branch, use:
IF
ELSIF
... ...
ELSIF
ELSE ...
END IF;
Loops are created with the following:
LOOP
END LOOP;
At least one of the statements in
EXIT WHEN
The loop breaks if
Some other useful loop-forming statements are:
- EXIT by itself is an unconditional loop break. Use it inside a conditional if you like.
- A WHILE loop can be formed with
WHILELOOP
END LOOP; - A simple FOR loop can be formed with:
FOR IN.. LOOP
END LOOP;
Here, can be any variable; it is local to the for-loop and need not be declared. Also,and are constants.