在编写存储过程的过程中需要用到类似于Java循环中continue的功能,但是发现开发环境数据库安装的是oracle 10g并不支持continue语句,现场的测试库和正式库都是使用的11g,11g是支持continue语句的。exit用来跳出循环,并不能到下一次循环。return跳出存储过程
查看oracle的版本信息 :用客户端连接到数据库,执行select * from v$instance 查看version项。
查看oracle的版本信息 :用客户端连接到数据库,执行select * from v$instance 查看version项。
这样在本地测试就需要单独编写一版存储过程,oracle 10g及以下使用goto来替代continue
begin
for i in 1..10 loop
if mod(i,2)=0 then
goto reapt point;
end if;
dbms_output.put_line(i);
<<reapt point>> ----要英文的两个尖括号
null;
end loop;
end;
<<reapt point>>标签后的null;语句不可少,因为goto标签后必须紧接着一个执行语句
或者自定义一个excption 来处理
begin
loop
exit when ...
declare
ex exception;
begin
if .. then
raise ex;
end if;
exception
when ex then
null;
end;
...
end loop;
end;
而正式环境只需要使用continue即可
begin
for i in 1..10 loop
if mod(i,2)=0 then
continue;
end if;
dbms_output.put_line(i);
end loop;
end;