概述
一:捕获错误异常
1:通过捕获Oralce系统中的预定义的错误异常。
2:通过捕获自定义的错误异常。
二:捕获错误异常的方法
在Oralce数据库对象体内。
1:定义错误异常变量
User_Exception EXCEPTION;
2: Begin
--执行Sql语句
Exception
when others then
null;
End;
实例:
create or replace procedure P_User_Pro(AL_ORDER_ID in NUMBER) is
Order_Id_Null EXCEPTION;--自定义错误异常
if AL_ORDER_ID = 0 or isnull(AL_ORDER_ID ) then
RAISE Order_Id_Null ;
end if;
Begin
update User_Table_Name
set order_state = '01'
where order_id = AL_ORDER_ID;
Exception
when others then
RAISE_APPLICATION_ERROR(-20014, '更新单据状态失败!错误:'|| SQLCODE || SQLERRM);
return ;
end;
Exception
when Order_Id_Null then--捕获自定义的错误异常
RAISE_APPLICATION_ERROR(-20015, '单据ID不正确!错误:'|| SQLCODE || SQLERRM);
rollback;
when other then
RAISE_APPLICATION_ERROR(-20016, '更新单据状态失败!错误:'|| SQLCODE || SQLERRM);
rollback;
end P_User_Pro;
最后
以上就是明亮黄豆为你收集整理的Oracle中函数,过程和触发器等的错误异常处理的全部内容,希望文章能够帮你解决Oracle中函数,过程和触发器等的错误异常处理所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复