PL / SQL异常

用户名
begin

  begin

     do something;

  exception

    when no_data_found then
      raise_application_error(-20000,"Message");

  end;

 exception

    when others then
        raise_application_error(-20000,"Other message");

 end;

我的问题是,当编译器捕获到“消息”错误时,它也捕获了“其他消息”错误。为什么会发生?

拉斐尔的老房子

尝试将它们放在相同的异常块中。

如果放在when others一个单独的块中,它将被提高,因为...没有already catched例外要排除others在该块之外。

来自文件

WHEN OTHERS子句用于捕获命名系统异常和命名程序员定义异常未处理的所有其余异常。

所以

exception

    when no_data_found then
      raise_application_error(-20000,"Message");

    when others then
      raise_application_error(-20000,"Other message");

end;

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章