1. CREATE OR REPLACE PROCEDURE sp_test_while_loop
    2. AS
    3. i_counter number := 10;
    4. BEGIN
    5. WHILE(i_counter > 0) LOOP
    6. dbms_output.put_line('In the loop i_counter is ' || to_number(i_counter) );
    7. i_counter := i_counter - 1;
    8. END LOOP;
    9. dbms_output.put_line('Out of the loop i_counter is ' || to_number(i_counter) );
    10. EXCEPTION
    11. NULL;
    12. END;
    13. /
    14. delimiter ;
    15. obclient>
    16. obclient> set serveroutput on;
    17. Query OK, 0 rows affected (0.00 sec)
    18. obclient> call sp_test_while_loop();
    19. Query OK, 0 rows affected (0.04 sec)
    20. In the loop i_counter is 10
    21. In the loop i_counter is 9
    22. In the loop i_counter is 8
    23. In the loop i_counter is 7
    24. In the loop i_counter is 6
    25. In the loop i_counter is 5
    26. In the loop i_counter is 4
    27. In the loop i_counter is 3
    28. In the loop i_counter is 2
    29. In the loop i_counter is 1
    30. Out of the loop i_counter is 0
    31. obclient>