Learn Oracle Database and Applications Here

PL/SQL Loop With Example

Looping is the basic fundamental thing of any programming language. It plays an important role in the iteration of records dynamically. PL/SQL loop is a very interesting topic as you have more than one methods to perform it.

Generally, if your requirement is that you need same code to be executed for multiple times, looping comes into the picture.

In this topic we will see below things:

Simple PL/SQL Loop

For Loop

While Loop

Labelling Loop

GOTO and CONTINUE

Simple PL/SQL Loop

In this looping method, written PL/SQL codes reside between LOOP and END LOOP. It is the simplest loop structure in PL/SQL.

Syntax,
LOOP
[...statements...];
END LOOP;

Note: There is no semi-colon after LOOP

This loop iterates until all the rows of the SQL statement are executed. In some conditions the loop iterates for infinite times which is of course not a good programming practice.

Thanks for stopping by at OracleMine.com. Speaking about my brief introduction, I work for a multinational organisation in Oracle related technologies. Being an avid blogger, I would like to inform you about my productivity and motivational blog XpressPlanet.com. Speaking of OracleMine.com, I will try my best to share knowledge on technologies in as simple and understandable manner as possible. You can also contribute your knowledge on OracleMine by writing to us at hioraclemine@gmail.com. Again I appreciate your visit. Hope to see you again and again!