Oracle通过DBLink访问远程数据库的LOB字段报ORA-22992的解决方法

Linux大全评论9.6K views阅读模式

最近在做一个照片采集的功能,照片采集是在外网库,而外网在把照片采集后,内网会读取外网库中的照片(照片字段是BLOB类型),如果内网直接通过select语句查询外网库的照片,则会报ORA-22992: cannot use LOB locators selected from remote tables的错误,网上查了一下解决方法,记录下来以便以后查看。

方法一:

内网建一个包含大字段(BLOB)的表,然后通过inser into … select … from …@dblink把数据插入到内网的库表中,直接操作内网库表即可。如:

创建表:

  1. SQL>create table inner_table select *from outer_table@dblink  

插入数据:

  1. SQL>insert into inner_table select *from outer_table@dblink  

这样就把外网表outer_table中的数据写到内网表inner_table中了。

方法二:

  1. SQL>create global temporary table tem_table( … ) on commit delete rows;  

插入数据:

  1. SQL> insert into tem_table select * fromouter_table@dblink;   
  2. xxx rows created.  

这样就把数据写到临时表了,不过提交之后数据就被删除了(临时表的特性)。 

其实这两种方法都差不多,只不过一个是用的临时表,一个是用的是永久性的表。

企鹅博客
  • 本文由 发表于 2020年4月8日 21:41:40
  • 转载请务必保留本文链接:https://www.qieseo.com/185357.html

发表评论