我在oracle 中有两个用户,A用户下面有一个表a, B用户下面有一个表b,
我能否在a表上建立触发器,当a表更新时,触发b表做更新?
如果可以的话,应该怎么做?请教!

解决方案 »

  1.   

    可以,首先a用户应该对b用户的b表有更新权限。
      

  2.   

    sample:create or replace trigger testT
      AFTER  UPDATE  ON A.a
      for each row 
    declare
      -- local variables here
    begin
      IF UPDATING THEN
         UPDATE b.b SET column_b=:NEW.coumn_b WHERE column_a=:OLD.a;
      END IF;
    end testT;
      

  3.   

    为什么我的就不行???
    create or replace trigger CAMPOXU_CHANGED after insert or update or delete
    on zladmin.campoxu for each row
    declare
        integrity_error exception;
        errno            integer;
        errmsg           char(200);
        /*idx              varchar2(50);*/begin
    if inserting then
        insert into kfadmin.test(kfadmin.test.test2,kfadmin.test.test3) values(:NEW.CID,:NEW.CNAME);
    elsif updating then
        update kfadmin.test set kfadmin.test.test2=:NEW.CID,kfadmin.test.test3=:NEW.CNAME where kfadmin.test.test2=:OLD.CID;
    elsif deleting then
        delete from kfadmin.test where kfadmin.test.test2=:OLD.CID;end if;
    exception
        when integrity_error then
           raise_application_error(errno, errmsg);
    end;
    结果说:表或者视图不存在!