The WHILE-LOOP statement executes the statements in the loop body as long as a condition is true:
WHILE condition LOOP
sequence_of_statements
END LOOP;
SET SERVEROUTPUT ON-- w w w. j a v a 2 s. com
DECLARE
counter INTEGER := 2;
BEGIN
counter := 0;
WHILE counter < 6 LOOP
counter := counter + 1;
DBMS_OUTPUT.PUT_LINE(counter);
END LOOP;
END;
/
The code above generates the following result.