SQL>
SQL> --Basic loop
SQL>
SQL>
SQL> SET SERVEROUTPUT ON
SQL> DECLARE
2 x NUMBER := 1;
3 BEGIN
4 LOOP
5 DBMS_OUTPUT.PUT_LINE('This loop has executed'||TO_CHAR(x)||' time(s)');
6 x := x +1;
7 EXIT WHEN x > 5;
8 END LOOP;
9 END;
10
11
12 /
This loop has executed1 time(s)
This loop has executed2 time(s)
This loop has executed3 time(s)
This loop has executed4 time(s)
This loop has executed5 time(s)
PL/SQL procedure successfully completed.
|