时间:2021-07-01 10:21:17 帮助过:30人阅读
--PL/SQL错误
编译时
运行时
--运行时的出错处理
EXCEPTION
--异常处理块
DECLARE
…
BEGIN
…
EXCEPTION
WHEN OTHERS THEN
handler_error(…);
END;
--用户自定义的异常
DECLARE
e_TooManyStudents EXCEPTION;
…
BEGIN
…
RAISE e_TooManyStudents;
…
EXCEPTION
WHEN e_TooManyStudents THEN
…
END;
--预定义的ORACLE异常
ORA-0001
DUP_VAL_ON_INDEX
ORA-0051
TIMEOUT_ON_RESOURCE
ORA-1001
INVALID_CURSOR
…
ORA-6533
SUBSCRIPT_BEYOND_COUNT
--触发异常
RAISE exception_variable
DECLARE
A EXCEPTION
BEGIN
…
RAISE A;
…
EXCEPTION
WHEN A THEN
…
END;
--处理异常
EXCEPTION
WHEN e_TooManyStudents THEN
INSERT INTO log_file(info)
VALUES(‘Major 1100 has ‘ || v_CurStudents || ’ max aloowed is ‘ || v_Max);
END;
--处理所有的异常
EXCEPTION
WHEN e_TooManyStudents THEN
…
WHEN OTHERS THEN
v_ErrCode := SQLCODE;
v_ErrText := SUBSTR(SQLERRM, 1, 200);
INSERT INTO log_file(code, message, info)
VALUES(v_ErrCode, v_ErrText, ‘ORACLE Error’);
END;
PL/SQL 08 异常 exception
标签:invalid handler bsp 异常 用户 ror source time other