While loop : While « PL SQL Statements « Oracle PL/SQL Tutorial






SQL> set serveroutput on
SQL> DECLARE
  2       just_a_num NUMBER := 1;
  3  BEGIN
  4       WHILE (just_a_num <= 10) LOOP
  5            dbms_output.put_line(just_a_num);
  6            just_a_num := just_a_num + 1;
  7       END LOOP;
  8  END;
  9  /
1
2
3
4
5
6
7
8
9
10

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