您的位置:首页 > 数据库 > Oracle

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

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

方法一:

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

创建表:

SQL>create table inner_table select *from outer_table@dblink


插入数据:

SQL>insert into inner_table select *from outer_table@dblink


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

方法二:

在本地创建一张和dblink远程端相同的全局临时表,然后在查询临时表:

--创建临时表:

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


插入数据:

SQL> insert into tem_table select * fromouter_table@dblink;
xxx rows created.这样就把数据写到临时表了,不过提交之后数据就被删除了(临时表的特性)。 

其实这两种方法都差不多,只不过一个是用的临时表,一个是用的是永久性的表。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息