While Loop In Oracle PL/SQL
The WHILE LOOP statement runs one or more statements while a condition is TRUE. The WHILE LOOP statement ends when the condition becomes FALSE or NULL, when a statement inside the loop transfers control outside the loop, or when PL/SQL raises an exception.
Syntax WHILE Loop In Oracle PL/SQL
WHILE Contitions
Loop Statements
END LOOP
While Loop in PL/SQL Example Code : Start With 1 to 10
DECLARE
i NUMBER :=0;
BEGIN
WHILE i < 10 LOOP
i:= i+1;
DBMS_OUTPUT.PUT_LINE('Current Number :'||i);
END LOOP;
END;
/
While Loop in PL/SQL Example Code : Start With 10 to 17
DECLARE
i NUMBER :=10;
BEGIN
WHILE i < 17 LOOP
i:= i+1;
DBMS_OUTPUT.PUT_LINE('Current Number :'||i);
END LOOP;
END;
/
While Loop in PL/SQL Example Code : Start & End With variables value
DECLARE
StartValue NUMBER := 10;
EndValue NUMBER := 20;
BEGIN
WHILE StartValue < EndValue LOOP
StartValue := StartValue + 1;
DBMS_OUTPUT.PUT_LINE('Current Number :'||StartValue);
END LOOP;
END;
/
No comments:
Post a Comment