PL/SQL跳出循环语句(EXIT,CONTINUE,GOTO,EXIT WEHN)操作实例源码如下:
-- Created on 2018/3/26 by E.WANG
/*
*/
declare
-- Local variables here
i integer:=0;
resutl int;
begin
/*
在PL/SQL编程语言中,EXIT语句有以下两种用法:
1.当循环中遇到EXIT语句循环立即终止,程序控制继续下一个循环语句后面。
2.如果使用嵌套循环(即一个循环内的另一个循环),EXIT指令将停止最内层循环的执行,并开始执行的下一行代码的程序段之后。
*/
dbms_output.put_line('----------------------exit---------------------');
<<forLoop_exit>>
for i in 1..10 loop
if i>8 then
--大于8时,退出循环
exit;
else
dbms_output.put_line('The ' || i || ' Times');
end if;
end loop forLoop_exit;
dbms_output.put_line('----------------------exit when---------------------');
<<forLoop_exitWhen>>
for i in 1..10 loop
--当能被5整除时,退出循环
exit when (mod(i,5)=0);
dbms_output.put_line('The ' || i || '