ORACLE 存储过程异常捕获并抛出
2017-09-20 18:51
316 查看
DECLARE
--声明异常
some_kinds_of_err EXCEPTION; -- Exception to indicate an error condition
v_ErrorCode NUMBER; -- Variable to hold the error message code
v_ErrorText VARCHAR2(200); -- Variable to hold the error message text
BEGIN
--...
--抛出异常
IF ( ... ) THEN --(括号内填抛出异常的条件)
RAISE some_kinds_of_err;
END IF;
--...
EXCEPTION
--捕捉异常
WHEN some_kinds_of_err THEN
/* do something to Handler the errors */
null;
--捕捉其他异常,并获得 捕获异常的内容
WHEN OTHERS THEN
v_ErrorCode := SQLCODE;
v_ErrorText := SUBSTR(SQLERRM, 1, 200);
-- Note the use of SUBSTR here.
dbms_output.put_line(v_ErrorCode || '::'||v_ErrorText);
END;
--声明异常
some_kinds_of_err EXCEPTION; -- Exception to indicate an error condition
v_ErrorCode NUMBER; -- Variable to hold the error message code
v_ErrorText VARCHAR2(200); -- Variable to hold the error message text
BEGIN
--...
--抛出异常
IF ( ... ) THEN --(括号内填抛出异常的条件)
RAISE some_kinds_of_err;
END IF;
--...
EXCEPTION
--捕捉异常
WHEN some_kinds_of_err THEN
/* do something to Handler the errors */
null;
--捕捉其他异常,并获得 捕获异常的内容
WHEN OTHERS THEN
v_ErrorCode := SQLCODE;
v_ErrorText := SUBSTR(SQLERRM, 1, 200);
-- Note the use of SUBSTR here.
dbms_output.put_line(v_ErrorCode || '::'||v_ErrorText);
END;
相关文章推荐
- ORACLE 存储过程异常捕获并抛出
- 关于python3捕获cx_oracle抛出的异常错误
- 触发器|存储过程 抛出异常——>oracle
- oracle plsql 捕获异常和抛出异常
- 解决python3捕获cx_oracle抛出的异常错误问题
- oracle中存储过程的三种异常捕获方式
- Spring事务异常回滚,捕获异常不抛出就不会回滚
- 抛出异常和捕获异常的区别
- Spring事务异常回滚,捕获异常不抛出就不会回滚
- 捕获Java线程池执行任务抛出的异常
- Python: 捕获异常然后再抛出另一个异常的正确姿势
- 异常抛出和捕获
- 106---oracle的PL/SQL,异常处理, 游标(CURSOR), 子程序,存储过程
- 异常 -- 捕获处理 &抛出处理
- Java中的异常处理:何时抛出异常,何时捕获异常?
- Spring事务异常回滚,捕获异常不抛出就不会回滚
- oracle开发学习篇之集合运算符以及集合异常捕获
- Spring事务异常回滚,捕获异常不抛出就不会回滚
- C++异常抛出与捕获及处理
- 异常捕获不抛出,Spring事务无法回滚