WHILE Loop : While Loop « PL SQL « Oracle PL / SQL






WHILE Loop

    
SQL>
SQL> DECLARE
  2     v_count PLS_INTEGER := 1;
  3  BEGIN
  4     WHILE v_count <= 20
  5     LOOP
  6        DBMS_OUTPUT.PUT_LINE('While loop iteration: '||v_count);
  7        v_count := v_count + 1;
  8     END LOOP;
  9  END;
 10  /
While loop iteration: 1
While loop iteration: 2
While loop iteration: 3
While loop iteration: 4
While loop iteration: 5
While loop iteration: 6
While loop iteration: 7
While loop iteration: 8
While loop iteration: 9
While loop iteration: 10
While loop iteration: 11
While loop iteration: 12
While loop iteration: 13
While loop iteration: 14
While loop iteration: 15
While loop iteration: 16
While loop iteration: 17
While loop iteration: 18
While loop iteration: 19
While loop iteration: 20

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.This script demonstrates variable visibility
15.The WHILE loop uses a loop index value as its gate on entry criterion:
16.While loop and number counter