exception
when others then
if sqlcode = 08177 then
result:=-201;
elsif sqlcode = '00054 then
result:=-101;
else
result:=-1;
end if;
end;
when others then
if sqlcode = 08177 then
result:=-201;
elsif sqlcode = '00054 then
result:=-101;
else
result:=-1;
end if;
end;
E1 exception ;
PRAGMA EXCEPTION_INIT(E1, -60);
begin
...
exception
when E1 then
...
end;
to : xinpingf(白开心) ,你的办法可以,我看大家还有看法没有,我今天结帖
when substr(sqlerrm,1,9) = 'ORA-08177' then --好象是大写
result:=-201;
--------------------------------------
end;
if substr(sqlerrm,1,9) = 'ORA-08177' then --好象是大写
result:=-201;
else
--------------------------------------
end if;
end;
to KingSunSha(弱水三千) ,你的做法好象不可以,异常处理中可以有“=”判断吗????
to : xinpingf(白开心) ,你的办法可以,我看大家还有看法没有,我今天结帖
异常中可以使用“=”的,不但可以使用等号,还可以使用任何的pl/sql语句declare
....
begin
...
exception
when others then
begin
...
exception
when ... then
...
end ;
end;这样都没有问题
---------- -
1SQL> declare
2 n number;
3 begin
4 select id into n from a where id >2;
5 exception
6 when others then
7 dbms_output.put_line(sqlcode);
8 dbms_output.put_line(sqlerrm);
9 end;
10 /
100
ORA-01403: 未找到数据PL/SQL 过程已成功完成。sqlcode = 100 ?? 这是怎么回事?
SQL> ed
已写入文件 afiedt.buf 1 declare
2 n number;
3 begin
4 select id into n from a where id =1;
5 exception
6 when others then
7 dbms_output.put_line(sqlerrm);
8 dbms_output.put_line(sqlcode);
9* end;
SQL> /
ORA-01422: 实际返回的行数超出请求的行数
-1422PL/SQL 过程已成功完成。
不好意思,我写成
when sqlcode = 08177 then了,
不好意思,你的方法是可以的