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;
这是使用Oracle xe trigger创建界面创建的触发器。
创建时没有错误,但是当在表上调用插入时,会显示错误
trigger failed -ORA-04098 is invalid and failed re-validation
。
指导和建议将有很大帮助。
答案 0 :(得分:3)
您应该使用:
REFERENCING new AS new
...
BEGIN
INSERT INTO fa1(s_id, name, class, sec)
VALUES (:new.reg_no, :new.name, :new.class, :new.sec);
...
答案 1 :(得分:0)
请注意,此select语句无效,因为没有inserted
select reg_no,name,class,sec
from inserted
编辑如果要将插入的值记录到表格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;
注意条款AFTER insert on "STUDENT_PERSONAL_DETAIL"
。我省略了or update or delete
以确保只会为新插入的记录触发此操作。 (因为你试图从'插入'表中选择,我得出的结论是你想要做的事情)