SQL>
SQL> --PL/SQL blocks can be nested, one inside the other.
SQL>
SQL> SET SERVEROUTPUT ON
SQL> DECLARE
2 error_flag BOOLEAN := false;
3 BEGIN
4 DBMS_OUTPUT.PUT_LINE('We are going to count from 100 to 1000.');
5 DECLARE
6 hundreds_counter NUMBER(1,-2);
7 BEGIN
8 hundreds_counter := 100;
9 LOOP
10 DBMS_OUTPUT.PUT_LINE(hundreds_counter);
11 hundreds_counter := hundreds_counter + 100;
12 IF hundreds_counter > 1000 THEN
13 EXIT;
14 END IF;
15 END LOOP;
16 EXCEPTION
17 WHEN OTHERS THEN
18 error_flag := true;
19 END;
20 IF error_flag THEN
21 DBMS_OUTPUT.PUT_LINE('Sorry, I cannot count that high.');
22 ELSE
23 DBMS_OUTPUT.PUT_LINE('Done.');
24 END IF;
25 END;
26 /
We are going to count from 100 to 1000.
100
200
300
400
500
600
700
800
900
Sorry, I cannot count that high.
PL/SQL procedure successfully completed.
SQL>