The WHILE loop uses a loop index value as its gate on entry criterion: : While Loop « PL SQL « Oracle PL / SQL






The WHILE loop uses a loop index value as its gate on entry criterion:

    
SQL>
SQL> DECLARE
  2    counter NUMBER := 1;
  3  BEGIN
  4    WHILE (counter < 5) LOOP
  5      dbms_output.put_line('Index ['||counter||'].');
  6      IF counter >= 1 THEN
  7        counter := counter + 1;
  8      END IF;
  9    END LOOP;
 10  END;
 11  /
Index [1].
Index [2].
Index [3].
Index [4].

PL/SQL procedure successfully completed.

SQL>

   
    
    
    
  








Related examples in the same category

1.Put two statement in while loop
2.Example of a WHILE loop that never executes
3.Corrected WHILE loop that executes
4.While Loop with condition
5.Change while loop counter
6.While loop with complex conditions
7.Insert value in while loop
8.Do calculation with while loop counter
9.Call EXIT to jump out of a while loop
10.Use EXIT WHEN to exit a while loop
11.WHILE..LOOP, Cursor Loop
12.WHILE Loop: This condition will evaluate to NULL, since v_Counter is initialized to NULL by default
13.WHILE Loop: Test the loop counter before each loop iteration to insure that it is still less than 50
14.WHILE Loop
15.This script demonstrates variable visibility
16.While loop and number counter