This paper describes the Oracle stored procedure loop syntax. For your reference, the details are as follows:
1. Simple cycle
grammar
loop
statements;
end loop;
example:
counter := 0;
loop
counter := counter + 1;
exit when counter = 5;
end loop;
Note: the exit statement immediately ends the loop, and the exit when statement stops the loop when the specified condition occurs (can appear anywhere in the loop code)
2. While loop
grammar
while condition loop
statements
end loop;
example:
counter := 0;
while counter < 6 loop
counter := counter + 1;
end loop;
3. For loop
grammar
for loop_variable in [reverse] lower_bound.. upper_bounder loop
statements
end loop;
example:
for count2 in 1..5 loop
DBMS_OUTPUT.PUT_LINE(count2);
end loop;
I hope this paper will be helpful to the Oracle database program design.