日期:2014-05-17 浏览次数:20846 次
create or replace trigger tr_after_update_t1 after update on t1 for each row begin insert into t2(id, name, cc) values(:new.id, :new.name, '00'); --:old.id, :old.name end;
------解决方案--------------------
楼上是写的更新时,我就写个插入时:
create or replace trigger tr_after_insert_t1
after insert on t1
for each row
begin
insert into t2(id, name, cc) values(:new.id, :new.name, '00'); --:old.id, :old.name
end;
:new代表新插入的表的数据,:old表时修改前的表的数据
------解决方案--------------------
create or replace trigger tr_after_update_t1
after insert or update on table1
for each row
begin
insert into table2(id, name, cc) values(:new.id, :new.name, '00');
end;
------解决方案--------------------
create or replace trigger tr_after_update_t1 after update,delete,insert on t1 for each row begin if inserting then insert into table2(id, name, cc) values(:new.id, :new.name, '00'); elsif updating then update table2 set name=:new.name,cc=:new.cc where id=:old.id; elsif deleting then delete from table2 where id=:old.id; end if; EXCEPTION WHEN others THEN null; end;
------解决方案--------------------