ORA-22992: 无法使用从远程表选择的 LOB 定位器

来源:互联网 发布:在淘宝店上怎样上图 编辑:程序博客网 时间:2024/06/05 14:26

执行:

    insert into incomesec.tp_ts_bill_info_b select * from incomesec.tp_ts_bill_info_b@DB_SYDB_LINK;insert

报错:ORA-22992: 无法使用从远程表选择的 LOB 定位器 


当出现这个错误的时候,那是因为你跨库连接查询中的这个表存在BLOB类型的字段

所以一定要注意,所有表中存在blob类型字段,
1.不能用 select * from 连接的表
2.不能将blob类型的字段出现在脚本中。。
如果这些blob类型的字段一定要导过来。。
可以先建立临时表再插入本地表。。
方法如下.在pl/sql中执行
第一步建临时表
create global temporary table foo
( X BLOB )
on commit delete rows;
第二步 插入本地表

insert into foo select blobcolumn from remoteTable@dl_remote ;


如果是把数据从一个库迁移到另一个库,还可以直接写个游标:


create or replace package body incomesec.PKG_INDB_CBSS is

  -- Private type declarations
  procedure in_db(v_resultcode out varchar2,
                  v_resultinfo out varchar2) is
     v_sql        varchar2(4000);

  Cursor objCur is
      select a.owner,a.obj_name,a.obj_links,a.ubj_name
      from u_param.td_sm_cbss_tables a;
  v_objCur      objCur%rowtype;
begin
     open objCur;
     loop
       fetch objCur
          into v_objCur;
        exit when objCur%notfound;
      v_sql:='drop table u_param.'||v_objCur.Ubj_Name||'';
       execute immediate v_Sql;
       commit;


       begin
       v_sql:='create table u_param.'||v_objCur.Ubj_Name||'
       as select * from '||v_objCur.Owner||'.'||v_objCur.Obj_Name||'@'||v_objCur.Obj_Links||'';
         execute immediate v_sql;
         commit;
       exception
         when others then
        rollback;
        v_resultcode := v_objCur.Obj_Name;
        v_resultinfo := SQLERRM;
        --DBMS_OUTPUT.put_line(v_resultinfo);
        return;
         end;
      end loop;
  close objCur;
end;


procedure in_db1(v_resultcode out varchar2,
                  v_resultinfo out varchar2) is
     v_sql        varchar2(4000);


  Cursor objCur is
      select * from all_tables a where a.OWNER = 'INCOMESEC' AND A.TABLE_NAME IN ('TF_F_USER_ZHIHUI_MID5_1','TF_F_USER_ZHIHUI_MID6_1','TF_F_USER_ZHIHUI_MID7_1','ZYN_TS_OP_CONTRACT_AUDIT','TS_S_JF_PARAM','TS_SY_RATE_GUO','TS_OF_WO_FAMILY_DEPART_NAME','TP_TS_USER_B','TP_TS_BILL_REPORT_LS','TP_TS_BILL_REPORT_B','TP_TS_BILL_INFO_LS','TP_TS_BILL_INFO_DETAIL_LS','TP_TS_BILL_INFO_DETAIL_B','TP_TS_BILL_INFO_B') order by table_name;
  v_objCur      objCur%rowtype;
begin
     open objCur;
     loop
       fetch objCur
          into v_objCur;
        exit when objCur%notfound;
        
      v_sql:='alter table INCOMESEC.'||v_objCur.table_name||' nologging';
       execute immediate v_Sql;
       commit;        
      v_sql:='delete from INCOMESEC.'||v_objCur.table_name||'';
       execute immediate v_Sql;
       commit;
       begin
       v_sql:='insert /*+append*/ into INCOMESEC.'||v_objCur.table_name||'
        select * from '||v_objCur.Owner||'.'||v_objCur.table_name||'@DB_SYDB_LINK';
         execute immediate v_sql;
         commit;
         
       v_sql:='alter table INCOMESEC.'||v_objCur.table_name||' logging';
       execute immediate v_Sql;
       commit;
       
       exception
         when others then
        --insert into table_bak values (v_objCur.table_name);
        v_resultcode := v_objCur.table_name;
        v_resultinfo := SQLERRM;
         end;
      end loop;
  close objCur;
end;


end PKG_INDB_CBSS;

0 0
原创粉丝点击