我有一个空白的表,为此设置了一个触发器:
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'
发布于 2018-03-21 01:08:38
您的触发器工作得很好,ORA-06512是调试模式的一部分,并告诉您您编码的ORA-20001代码行。而ORA-04088说触发器中发生了错误。这两个错误代码都是oracle故障排除报告的通用部分。
发布于 2018-03-21 01:15:37
根据文档
ORA-06512:在字符串处 原因:当堆栈被未处理的异常打开时,返回跟踪消息。
基本上,此错误是错误堆栈的一部分,它指示实际错误发生在哪一行。
和文档
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;
https://stackoverflow.com/questions/49396379
复制相似问题