An anonymous block demonstrates a guard on exit simple loop
SQL>
SQL> DECLARE
2 counter NUMBER;
3 first BOOLEAN;
4 BEGIN
5 LOOP
6 IF NVL(counter,1) >= 1 THEN
7 IF NOT NVL(first,TRUE) THEN
8 counter := counter + 1;
9 ELSE
10 counter := 1;
11 first := FALSE;
12 END IF;
13 END IF;
14 dbms_output.put_line('Iteration ['||counter||']');
15
16 EXIT WHEN NOT counter < 3;
17 END LOOP;
18 END;
19 /
Iteration [1]
Iteration [2]
Iteration [3]
PL/SQL procedure successfully completed.
SQL>
Related examples in the same category