0% found this document useful (0 votes)
18 views2 pages

Types of PL/SQL Loops Explained

Uploaded by

Dhavan Ravuri
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views2 pages

Types of PL/SQL Loops Explained

Uploaded by

Dhavan Ravuri
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

Loops:

used to repeat a process n number of times


PL/SQL supports three types of Loops
1. loop .. end loop
[Link] loop .. end loop
[Link] loop
loop:
* Repeat the a group of statements n number of times
* It will stop the execution when given condition is true.
syn:
loop
statements
exit when condition;
end loop;
ex:
declare
i number:=1;
begin
loop
dbms_output.put_line(i);
i:=i+1;
exit when i=10;
end loop;
end;

while loop:
* it will test the condition, if condition true, then it will execute the
statements.
* Repeat the process until the condition is false.
syn:
while condition loop
statements;
end loop;
ex:

declare
i number:=1;
begin
while i<=10 loop
dbms_output.put_line(i);
i:=i+1;
end loop;
end;

for loop:
* Used to repeat a process n number of times
* It will repeat the process based in given range of value
syn:
for variable in start .. stop loop
statements
end loop;
ex:
declare
i number;
begin
for i in 1 .. 10 loop
dbms_output.put_line(i);
end loop;
end;

You might also like