Oracle pl sql for in loop tutorial
Pl sql for in loop:
The pl sql for in loop repeatedly executes a block of statements for a fixed number of times. The loop iteration occurs between the start and end integer values. The counter is always incremented by 1 and loop terminates when the counter reaches the value of the end integer.
Pl sql for in loop syntax:
FOR loop_counter IN [REVERSE] start_value .. end_value
//block of statements.
1. The double dot (..) specifies the range operator.
2. By default iteration is from start_value to end_value but we can reverse the iteration process by using REVERSE keyword.
3. No need to declare the counter variable explicitly because it is declared implicitly in the declaration section.
4. The counter variable is incremented by 1 and does not need to be incremented explicitly.
5. The EXIT and EXIT WHEN statements can be used.
Pl sql for in loop example:
FOR var IN 1..10
Pl sql for in loop reverse example:
FOR var IN REVERSE 1..10