create trigger tri_ins
after insert
on table1
begin
insert into table2
select :new.id ,row1,row2 where from table3 where :new.id=id;
end;
/
after insert
on table1
begin
insert into table2
select :new.id ,row1,row2 where from table3 where :new.id=id;
end;
/
楼上的正确,但要注意table3 的id是否唯一!
after insert
on table1
begin
insert into table2
select :new.id ,row1,row2 where from table3 where id = :new.id and rownum = 1;
end;
after insert
on table1
begin
insert into table2
select :new.id ,row1,row2 where from table3 where id = :new.id and rownum = 1;
end;
ERROR 位于第 6 行:
ORA-04082: NEW 或 OLD 引用不允许在表层触发器中应该是 :new.id 的原因吧,可是我该怎么改呢?
after insert改为before insert应该不会出现上面的错误了。
before insert on table1
for each row
begin
insert into table2
select :new.id ,row1,row2
from table3 where id = :new.id and rownum = 1;
end;
警告: 创建的触发器带有编译错误
这个触发器可以用吗?
after insert
on table1
referencing old as old new as new
for each rowbegin
insert into table2
select :new.id ,row1 ,row2
from table3
where id = :new.id and rownum = 1;
end;
before insert on table1
for each row
begin
insert into table2 select id ,row1 ,row2 from table3 where id = :new.id;
end;
他说是insert into table2这一行没有足够的值,table2 table3都有id,row1,row2字段阿