--自定义异常(业务数据存在异常,非oracle错误)
create or replace procedure my_exception
(
p_messge out t_name.name%type
)
as
cursor names is select * from t_name t where t.age<0;--游标取值
myexception Exception;--声明变量
pragma exception_init(myexception,-20001);--自定义异常
begin
for name in names
loop
if name.age<0 then
raise myexception;
else
p_messge:='业务数据正常';
end if;
end loop;
exception
when myexception then p_messge:='业务数据存在负数';
end my_exception;
create or replace procedure my_exception
(
p_messge out t_name.name%type
)
as
cursor names is select * from t_name t where t.age<0;--游标取值
myexception Exception;--声明变量
pragma exception_init(myexception,-20001);--自定义异常
begin
for name in names
loop
if name.age<0 then
raise myexception;
else
p_messge:='业务数据正常';
end if;
end loop;
exception
when myexception then p_messge:='业务数据存在负数';
end my_exception;
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/26364008/viewspace-2133242/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/26364008/viewspace-2133242/