Nested WHILE Loop : While « PL SQL Statements « Oracle PL/SQL Tutorial






SQL>
SQL>
SQL> declare
  2      v_ind     NUMBER;
  3      v_current NUMBER;
  4  begin
  5      v_current:=0;
  6      while v_current<=25
  7      loop
  8          v_ind:=0;
  9          while v_ind<4
 10          loop
 11              v_ind:= v_ind+1;
 12              DBMS_OUTPUT.put_line(v_current);
 13          end loop;
 14          v_current:=v_current+5;
 15      end loop;
 16  end;
 17  /
0
0
0
0
5
5
5
5
10
10
10
10
15
15
15
15
20
20
20
20
25
25
25
25

PL/SQL procedure successfully completed.

SQL>








22.7.While
22.7.1.WHILE Loops
22.7.2.While loop
22.7.3.WHILE LOOP with counter
22.7.4.Calculate circle Area in WHILE loop
22.7.5.Example of a WHILE loop that never executes.
22.7.6.The EXIT and EXIT WHEN Statements
22.7.7.EXIT a WHILE LOOP with exit command
22.7.8.While Counter is initialized to NULL
22.7.9.Nested WHILE Loop
22.7.10.Use WHILE Loop to insert data to table
22.7.11.A complete example of using the cursor variable using a WHILE LOOP