Note: This article comes from: " Writing Method of Jumping Out of Loop in Oracle Stored Procedure "
How to write out of loop in Oracle stored procedure
Record the usage of exit and return
1: exit is used to jump out of the loop
2: return to jump out of the stored procedure
3: Jump out of the loop once
Oracle 11g has provided continue;
oracle 10g and below, use goto instead, for example1 SQL> set serveroutput on; 2 SQL> declare 3 2 begin 4 3 for i in 1..10 loop 5 4 if mod(i,2)=0 then 6 5 goto next; 7 6 end if; 8 7 dbms_output.put_line(i); 9 8 <<next>> 10 9 null; 1110 end loop; 12 11 end ; 13 12 / 14 Note: The null; statement after the << next >> label is indispensable, because the goto label must be followed by an execution statement
————————————————————————————————————————————————————————————————————————————————————————————————