Oralce数据库常用预定义例外:
EXCEPTION
WHEN CURSOR_ALREADY_OPEN THEN-- ORA-06511 SQLCODE = -6511 游标已经打开
WHEN DUP_VAL_ON_INDEX THEN
-- ORA-00001 SQLCODE = -1 向唯一索引中插入重复数据
WHEN INVALID_CURSOR THEN
-- ORA-01001 SQLCODE = -1001 非法游标操作
WHEN INVALID_NUMBER THEN-- ORA-01722 SQLCODE = -1722 字符向数字转换失败
WHEN LOGIN_DENIED THEN
-- ORA-01017 SQLCODE = -1017
WHEN NO_DATA_FOUND THEN
-- ORA-01403 SQLCODE = +100 没有找到数据
WHEN NOT_LOGGED_ON THEN
-- ORA-01012 SQLCODE = -1012
WHEN PROGRAM_ERROR THEN
-- ORA-06501 SQLCODE = -6501 程序错误
WHEN STORAGE_ERROR THEN
-- ORA-06500 SQLCODE = -6500
WHEN TIMEOUT_ON_RESOURCE THEN
-- ORA-00051 SQLCODE = -51
WHEN TOO_MANY_ROWS THEN-- ORA-01422 SQLCODE = -1422 返回多行
WHEN TRANSACTION_BACKED_OUT THEN
-- ORA-00061 SQLCODE = -61
WHEN VALUE_ERROR THEN
-- ORA-06502 SQLCODE = -6502 数值转换错误
WHEN ZERO_DIVIDE THEN
-- ORA-01476 SQLCODE = -1476 被零除
WHEN OTHERS THEN-- 其它任何错误的处理
END;
--用户定义的例外
DECLARE
FIND_DATA_EMP EXCEPTION;
BEGIN
IF ... THEN
RAISE FIND_DATA_EMP;
END IF;
EXCEPTION
WHEN LOB_NO_LOCKED THEN
...
END;