注:本文来源于: 《 Oracle存储过程中跳出循环的写法 》
Oracle存储过程中跳出循环的写法
记录exit和return的用法
1:exit用来跳出循环
2:return跳出存储过程
3:跳出loop 一次循环
oracle 11g已提供continue;
oracle 10g及以下,使用goto来替代,例如1 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; 11 10 end loop; 12 11 end; 13 12 / 14 注意:<<next>>标签后的null;语句不可少,因为goto标签后必须紧接着一个执行语句
扫描二维码关注公众号,回复: 31964 查看本文章
————————————————————————————————————————————————————————————————————————————————————————————————