Oracle SQL,PL/SQL

Oracle PL/SQL Loop: Basic Loop, While Loop ,For Loop and Continue Statement

Oracle PLSQL Loop
Avatar of shohal
Written by shohal

Oracle PL/SQL Loop Structure and Example

Basic Loop Structure :

DECLARE
X NUMBER:=0;
BEGIN
Loop
x:=x+1;
exit when x>=5;
dbms_output.put_line(x);
end loop;
END;

Output:

1
2
3
4

While Loop Structure:

Declare
x number:=0;
begin
while x<=5 loop
x:=x+1;
dbms_output.put_line(x);
end loop;
end;

Output :

1
2
3
4
5
6

For Loop Structure :

 Declare
 x number:=0;
 begin
 for x in 1..5 loop
 dbms_output.put_line(x);
 end loop;
 end;

Output:

1
2
3
4
5

Continue Statement Structure :

 Declare
 x number:=0;
 begin
 for x in 1..5 loop
 if x=1 then
 continue;
 end if;
 dbms_output.put_line(x);
 end loop;
 end;

Output :

2
3
4
5

🚀
Oracle PL/SQL Loop: Basic Loop, While Loop ,For Loop and Continue Statement | TechTweet

If you’d like me to proceed with any of these, please just let me know from the site techtweet.xyz! Also if you need to learn something new than subscribe YouTube : ASP.NET With SQL SERVER

About the author

Avatar of shohal

shohal

I have profession and personal attachment with custom ERP Software development, Business Analysis, Project Management and Implementation almost (36) ,also Oracle Apex is my all-time favorite platform to developed the software. Moreover i have some website development experience with WordPress. For hand on networking experience DevOps and CCNA, it create me a full package. Here are some core programming language with networking course i have been worked: Oracle SQL ,PL/SQL,Oracle 19c Database , Oracle Apex 20.1,WordPress,Asp.Net ,MS SQL ,CCNA ,Dev Ops, SAP SD