A B两个用户各有同名同结构的表tab,在B下创建一触发器,从B的tab里查找记录插入到A表,但在B的触发器里调用A.tab提示“表或视图不存在”,该怎么调用?

解决方案 »

  1.   

    你是2个数据库还是同一个数据库的两个用户,
    2个库之间要建DBLINK
    不同用户之间要 用户名.表名。
      

  2.   

    不同用户,我引用的时候是用的A.tab,但也提示那错
      

  3.   

    你参考下:
    create or replace trigger trg_AAA_TRI
    after insert or update or delete on AAA_TRI
    for each row
    declare
            str_action varchar2(32);
            str_sql    varchar2(32000);
            i_sqlcode  int;
    begin
        if inserting then
            str_action := 'inserting' ;
           --INSERT字段名由select table_name from user_tab_columns where table_name=:table_name;动态生成
            insert into AAA_TRI@db205(AAA,BBB) values(:new.AAA,:new.BBB);
        end if;    if updating then
            str_action := 'updating' ;
            --更新字段名由select table_name from user_tab_columns where table_name=:table_name;动态生成
            --条件字段名由st_tblsync的primary_fields动态生成
            update AAA_TRI@db205 set AAA=:new.AAA,BBB=:new.BBB
            where 1=1   and aaa =:old.aaa and bbb =:old.bbb;
        end if;    if deleting then
            str_action := 'deleting' ;
            --条件字段名由st_tblsync的primary_fields动态生成
            delete from AAA_TRI@db205
            where 1=1  and aaa =:old.aaa and bbb =:old.bbb;
        end if;
    end;
      

  4.   

    1.创建同义词CREATE PUBLIC SYNONYM tablename FOR tablename;
    2.赋权GRANT SELECT ON tablename TO userb;