触发器做不了,9i可以用以下语句:
当a表与b表有相记录,就更新,否则就插入
merge into table1 a
using(select * from table2 b) 
on (a.id=b.id) 
when matched then 
update set fno='old' 
when not matched then 
insert into values(a.id,'new');

解决方案 »

  1.   

    ??  用instead of insert 不是可以判断吗?
    不过只试用与一条一条的数据,
    1楼的适用于批量数据,而且性能得到9i 的优化
      

  2.   

    create trigger insert_tr 
    befor update,insert on table_name
    for each row
    declare
     v_a char(20);
    v_b char(20);
    begin
     declare cursor curtest is select a,b from table_name;
     open curtest;
     fetch curtext into v_a,v_b;
     if(v_a=:new.a) then
      update teble_name set b=:new.b;
     end if;
     loop;
     close curtest;
    insert into table_name(a,b) vaules(:new.a,:new.b);
    end insert_tr ;
      

  3.   

    update teble_name set b=:new.b;
    insert into table_name(a,b) vaules(:new.a,:new.b);
    这两句同时出现死循环
      

  4.   

    beckhambobo(beckham)说的对, vrv0129() 的代码会出现死循环,不知道可不可以有判断某个字段是否更改的呢?有兴趣和我一起探讨Oracle的请加我:yc_zyk@hotmail!