PRAGMA EXCEPTION_INIT:
命名未命名的内部异常,在编译时处理;
例如:
declare
……
exp exception;
PRAGMA Exception_Init(exp, -2292);
begin
……
exception when exp then
……
end;
/RAISE_APPLICATION_ERROR:
抛出自定义异常
语法:raise_application_error(error_number, message[, {TRUE | FALSE}]);
·error_number范围:-20000至-20999
·message是最大长度为2048字节的字符串。
·参数为TRUE的话,错误就会被放到前面错误的栈顶。如果为FALSE(默认值),错误就会替代前面所有的错误。
例如:
begin
……
raise_application_error (-20101, 'Salary is missing');
……
end;
/抛出PLSQL异常:
例如:
declare
exp exception;
begin
……
if ……
raise exp;
……
exception when exp then
……
end;
/
本文详细介绍了PLSQL中异常处理的基本概念与应用方法,包括如何使用PRAGMA EXCEPTION_INIT命名未命名的异常,如何通过RAISE_APPLICATION_ERROR抛出自定义错误,以及如何在程序中声明并抛出PLSQL异常。
2215

被折叠的 条评论
为什么被折叠?



