ORA-04088:执行触发期间出错 - 其他错误

时间:2018-03-21 00:41:59

标签: sql oracle

我有一张空白表,我已经设置了一个触发器:

CREATE OR REPLACE TRIGGER   authors_bir
BEFORE INSERT ON authors
FOR EACH ROW

begin
  if upper(:new.name) = 'TEST' then
    raise_application_error(-20001, 'Sorry, that value is not allowed.');
  end if;
end;

执行后:

insert into AUTHORS
    VALUES (1, 'test', '1-Jan-1989', 'M');

除了预期的ORA-20001错误提示外,为什么还会收到ORA-06512和ORA-04088错误消息?

的ErrorMessage

Error starting at line : 5 in command -
insert into AUTHORS
    VALUES (1, 'test', '1-Jan-1989', 'M')
Error report -
ORA-20001: Sorry, that value is not allowed.
ORA-06512: at "RPS.AUTHORS_BIR", line 3
ORA-04088: error during execution of trigger 'RPS.AUTHORS_BIR'

2 个答案:

答案 0 :(得分:2)

您的触发器工作正常,ORA-06512是调试模式的一部分,并告诉您编写的ORA-20001代码行。虽然ORA-04088表示触发器中发生了错误。这两个错误代码都是oracle故障排除报告的GENERIC部分。

答案 1 :(得分:0)

根据documentation

  

ORA-06512:at stringline string

     

原因:由于未处理的异常解除了堆栈的回溯消息。

基本上,这个错误是错误堆栈的一部分,告诉实际错误发生在哪一行。

documentation

  

ORA-04088:执行触发器'string.string'时出错

     

原因:执行触发器时发生运行时错误。

此错误是错误堆栈的一部分,告诉您错误实际发生在触发器中。

发生未处理的错误时,始终显示错误堆栈。如果您只想显示错误消息,可以使用异常处理部分,因此触发器的主体看起来像这样:

begin
  if upper(:new.name) = 'TEST' then
    raise_application_error(-20001, 'Sorry, that value is not allowed.');
  end if;
exception
  when others then
    dbms_output.put_line(sqlcode|' '|sqlerrm);
end;