create or replace trigger table1_TRIGGER
  before insert on table1
  for each rowdeclarebegin
  if inserting then
    insert into B.table1(c1,c2,c3,c4)
      values(sysdate,:new.c2,:new.c3,'0');
  end if;
exception
  when OTHERS then
        raise_application_error(-20002,'table1 trigger error');
end table1_TRIGGER;B.table1的地方报错,问题出在哪?该如何修改?谢谢

解决方案 »

  1.   

    授予insert权限了吗?
    grant insert on B.table1 to A
      

  2.   

    好像是B.table1这个写法不对。
      

  3.   

    B用户下:
    grant all on table1 to A;
    A用户下建触发器:
    Create Or Replace Trigger TRIGGER_NAME
    After Insert Or Update Or Delete On A.TABLE1
      For Each ROW
    Begin
       --当操作类型为增加时
       IF INSERTING THEN
          INSERT INTO B.table1(c1,c2...)
          VALUES(NEW.c1,NEW.c2...);
       --当操作类型为修改时
       ELSIF UPDATING THEN
          UPDATE b.table1 SET c1 = NEW.c1,c2=NEW.c2,...
           WHERE c1=OLD.c1 AND c2=OLD.c2 AND ...;
       ELSIF DELETING THEN
           DELETE FROM  b.table1 
           WHERE c1=OLD.c1 AND c2=OLD.c2 AND ...;
        --只有old值
       END IF;
    END TRIGGER_NAME;