While Loop:
In Oracle,we use while loop if we are not sure how many times we need to execute particular LOOP or that LOOP may not execute even once also.
Syntax:
WHILE (CONDITION)
LOOP
STATEMENTS;
END LOOP;
Here condition is to pass the LOOP,if condition is satisfied then it ill continue LOOP otherwise it will terminate LOOP.
Example:
while (v_sal < 10000)
loop
v_sal := sal * comm;
End loop;
here while loop will check condition first,here condition is v_sal should be less than 10000.So until v_sal becomes 1000 this loop will get executed but once it becomes 10000 then it ill terminate LOOP.
In Oracle,we use while loop if we are not sure how many times we need to execute particular LOOP or that LOOP may not execute even once also.
Syntax:
WHILE (CONDITION)
LOOP
STATEMENTS;
END LOOP;
Here condition is to pass the LOOP,if condition is satisfied then it ill continue LOOP otherwise it will terminate LOOP.
Example:
while (v_sal < 10000)
loop
v_sal := sal * comm;
End loop;
here while loop will check condition first,here condition is v_sal should be less than 10000.So until v_sal becomes 1000 this loop will get executed but once it becomes 10000 then it ill terminate LOOP.
No comments:
Post a Comment