create or replace procedure xxx is ..... begin begin select statement exception statement return; end; ... begin select statement exception statement return; end; final statements end;
不行啊,return就直接跳出程序了。
我一般的做法是先判断select能不能取到记录。不能的话,跳转到下面的语句。 select count(*) into li_count from **** if li_count>0 then /*正常往下*/ else select count(*) into ********** end if;我也想知道有没有更好的方法。
把你的code贴出来看有没有好的解决方法,问题有点笼统
SELECT * INTO jl FROM table WHERE 条件1 AND ROWNUM = 1;若查询到记录,则处理记录,若没有,则用条件2查找SELECT * INTO jl FROM table WHERE 条件2 AND ROWNUM = 1;有希望查不到记录的时候不要抛出异常,跳出程序,能让我判断有没有查到,然后决定是否要用条件2继续查找,因为有三组条件,若用异常比较麻烦,而且很不好看。
create or replace procedure xxx is ..... begin begin select statement exception statement end; ... begin select statement exception statement end; final statements end;
那种方法是可以,不过应该比较浪费性能啊,CodeMagic能不能详细说一下你的方法呢?
begin select statement exception statement end;加了begin end的目的是防止嵌套层数过多,代码不用缩进,好看些
.....
begin begin
select statement exception statement return;
end; ... begin
select statement exception statement return;
end; final statements
end;
select count(*) into li_count from ****
if li_count>0 then
/*正常往下*/
else
select count(*) into **********
end if;我也想知道有没有更好的方法。
.....
begin begin
select statement exception statement end; ... begin
select statement exception statement end; final statements
end;
begin
select statement exception statement end;加了begin end的目的是防止嵌套层数过多,代码不用缩进,好看些