PL/SQL While Loop

PL/SQL While Loop

The Loop statement WHILE-LOOP run so long as the condition is true.

Syntax:

WHILE condition 
LOOP sql_statements 
LOOP END;

Example:

DECLARE 
	x NUMBER:=0; 
BEGIN 
WHILE x < 5
LOOP 
	x:= x + 1; 
	DBMS_OUTPUT.PUT_LINE (' x= ' || x);  
END LOOP; 
END;