ORA-20001,ORA-06512:第59行ORA-06512异常错误

时间:2016-02-14 22:39:42

标签: oracle exception plsql

这是我定义异常的PL / SQL块的一部分。当我的数据不包含任何异常但在有异常时生成错误消息时,它运行正常。错误消息如下:" ORA-20001:分数更改无效。 ORA-06512:第59行 ORA-06512:第73行"

我想知道它出了什么问题。有人可以帮我从这里出去吗?感谢。

begin

   if (newpoints<0 or newpoints>maximumpoints) then 
            raise invalid_score_change;
         end if; 
exception 
      when invalid_score_change then
         raise_application_error(-20001,'Invalid score change.');
end;

1 个答案:

答案 0 :(得分:0)

即使正如其他人所建议的那样,该程序正如您所说的那样完成 - 您的问题是您有一个未绑定的异常导致您要删除的外部ORA-06512。你的问题是你已经引发了异常而没有处理程序。如果你不想看到ORA-06512消息,你需要通过包装另一个异常处理程序来处理这样的异常 - 顺便说一下,我认为这不是一个好习惯,但我只是回答你的问题。

begin
    begin

       if (newpoints<0 or newpoints>maximumpoints) then 
            raise invalid_score_change;
       end if; 
     exception 
       when invalid_score_change then
       raise_application_error(-20001,'Invalid score change.');
       --- you are now throwing and unhandled exception to be caught by the next handler below
    end;
 exception
     when others then
       ----- do something
     null; -- just to get it to compile
 end;