How to Work With FOR Loop Statements in PL/SQL
In this article I am going to explain how to work with for 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 FOR LOOP Statement
Simple FOR loops statement iterate over a specified range of integers in PL SQL.
FOR counter IN lower_bound .. higher_bound LOOP
Example of FOR Loop Statement
max_value CONSTANT INT :=10;
x int :=1;
FOR x IN 1 .. max_value loop
INSERT into record_info VALUES (x, sysdate);