其实流程并不麻烦,我写得比较详细,希望大家帮帮忙。  假设系统有2张表,mainTable(主表)和tempTable(中转表)
当表,mainTable(主表)发生insert,update事件时(假设不考虑并发访问该表),利用触发器把 mainTable中被insert,update更新之后的数据,和更新的操作(以字符串的形式,如’Update’或‘Insert’)插入一张临时表(tempTable)中,   因此最后tempTable中就包括mainTable更新之后的更条数据 和所对应的操作即insert或update对应的触发器如何写?谢谢。

解决方案 »

  1.   

    create or replace trigger test_tr
    after insert or update on mainTable
    for each row
    begin
    if inserting then
    insert into tempTable values(:new.字段,'insert');
    elsif updating then
    insert into tempTable values(:new.字段,'update');
    end if;
    end;
    /
      

  2.   

    我也试着写出来了,不过没有你的精简,我知道能用if inserting then和elsif updating then,所以写了2条触发器分别对应update 和insert.
    谢谢解答!给分