PL/SQL Loops , Iterative Statement in PL/SQL

Sharing is Caring

PL/SQL Loops are used to repeat execution of a statement or a set of statements multiple times on base of a condition or expression
EXIT and EXIT-WHEN keywords are used to terminate the loop when desired.

EXIT– terminates the loop unconditionally and passes control to the next statement after the loop
EXIT-WHEN– terminates the loop when EXIT-WHEN clause is checked and if returns true then the loop is terminated and control is passed to next statement after the loop

The basic syntax of Loop in PL/SQL is like this, a set of statements are put inside a block of loop keyword to execute n-number of times.


Set of statements


Types of Loops in PL/SQL


PL/SQL Loops

There are 3 types of loops in PL/SQL

PL/SQL Basic/Exit Loop- In this loop all statements inside the loop are executed at least once and the loop terminates when exit condition is true ..Read in detail

PL/SQL While Loop– Loop continues while a given condition is true and the condition is tested before iteration of statements ..Read in detail

PL/SQL For Loop- Statements are executed for a defined number of times (between two values of the counter variable) as declared in for loop ..Read in detail

Cheers 🙂 Happy Learning

Related Posts

Leave a Reply

Your email address will not be published. Required fields are marked *