oracle 触发器失败 -ORA-04098 无效且重新验证sql失败
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/12693635/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
trigger failed -ORA-04098 is invalid and failed re-validation sql
提问by ashtom
create or replace trigger "STUDENT_PERSONAL_DETAIL_T1"
AFTER insert or update or delete on "STUDENT_PERSONAL_DETAIL"
for each row
begin
insert into fa1 (s_id,name,class,sec)
select reg_no,name,class,sec
from inserted
end;
This is the trigger created using Oracle xe trigger creating interface.
这是使用Oracle xe 触发器创建界面创建的触发器。
It is created without error but when a insert is called on the table trigger error is shown
trigger failed -ORA-04098 is invalid and failed re-validation
.
它创建时没有错误,但在表上调用插入时会显示触发器错误
trigger failed -ORA-04098 is invalid and failed re-validation
。
Guidance and suggestions will help a lot.
指导和建议会有很大帮助。
回答by Benoit
You should use:
你应该使用:
REFERENCING new AS new
...
BEGIN
INSERT INTO fa1(s_id, name, class, sec)
VALUES (:new.reg_no, :new.name, :new.class, :new.sec);
...
回答by bpgergo
see, this select statement is invalid, because there is no such table as inserted
看,这个select语句是无效的,因为没有这样的表 inserted
select reg_no,name,class,sec
from inserted
EDITif you want to log the inserted values into table fa1, you would do something like, if you had the following columns in table STUDENT_PERSONAL_DETAIL
: reg_no,name,class,sec
编辑如果你想将插入的值记录到表 fa1 中,你会做类似的事情,如果你在表中有以下列STUDENT_PERSONAL_DETAIL
:reg_no,name,class,sec
create or replace trigger "STUDENT_PERSONAL_DETAIL_T1"
AFTER insert on "STUDENT_PERSONAL_DETAIL"
for each row
begin
insert into fa1 (s_id,name,class,sec)
values (:new.reg_no, :new.name, :new.class, :new.sec)
end;
Note the clause AFTER insert on "STUDENT_PERSONAL_DETAIL"
. I have omitted or update or delete
to make sure this will only be triggered for newly inserted records. (because you tried to select from table 'inserted', I have concluded that's what you want to do)
注意子句AFTER insert on "STUDENT_PERSONAL_DETAIL"
。我没有or update or delete
确保这只会为新插入的记录触发。(因为您尝试从“插入”表中进行选择,所以我得出结论,这就是您想要做的)