How to Work With LOOP Statements in PL/SQL
In this article I am going to explain how to work with loop statements in PL/SQL.
PL/SQL is define as procedure language/structure query language. PL/SQL is developed by oracle. PL/SQL supports many feature like variables, loops, conditions and exceptions. It also support the concept of array. In present time PL/SQL is integrated component of oracle software. SQL provide limited support for advance programming and PL/SQL fill this gap.
Block is a basic unit of a PL/SQL application. This block is collection of PL/SQL statements grouped as logical unit. Using PL/SQL blocks you can create five different type of program units.
- Stored Function
- Stored procedure
- Anonymous Block
LOOP statements execute a sequence of statements multiple times. There are three types of LOOP statements
- WHILE - LOOP
- FOR - LOOP
Work with LOOP Statement
The basic loop is the simplest form of LOOP statement in PL/SQL.
Example of While Loop Statement
x positive :=1;
max_value CONSTANT positive := 10;
x := x+1;
EXIT WHEN x>max_value;