PL/SQL raise handled exception

穿精又带淫゛_ 提交于 2021-01-29 04:36:37

问题


How can I throw cached exception in PL/SQL?

For example I have procedure, where I catch all exceptions:

  EXCEPTION
   WHEN OTHERS THEN
      rollback;

and then I want to throw catched exception to procedure caller.

Thanks in advance!


回答1:


Just add raise;:

EXCEPTION
  WHEN OTHERS THEN
    rollback;
    raise;



回答2:


To re-raise the exception, just use

raise;

To define a custom application error, look at raise_application_error, e.g.

raise_application_error(-20001, 'Warp core implosion imminent', true);

It's worth bearing in mind that due to what I've just decided to call the Exception Handling Uncertainty Principle, there is always a trade-off between reporting the full exception details and doing something about the exception.



来源:https://stackoverflow.com/questions/38767142/pl-sql-raise-handled-exception

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!