ora-22992 通过DBLINK 访问远程CLOB表问题

 

在本地用select语句访问远程,如果远程表有CLOB字段的话则会有错:ora-22992;
如果真的想看到clob字段的内容的话就得在本地建立一个表,用下面两条语句:
我刚才试验insert into table select * from remote table成功
remote table含有CLOB
总结:在我的环境中成功
(1)create table aaa select * from remote table
(2)insert into table select * from remote table


不过网上也有以下说法,虽然有错,不过也是一种方法,

通过临时表从DBLink中获取Blob对象2006-12-05 20:37做系统集成时,通过Database Link共享数据是不错的选择。不过真正使用DBLink时却碰到一个不小的问题:从远程数据库上查询Blob字段时总返回ORA-22992错误,如下:

select blobcolumn from remoteTable
@dl_remote;

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

查找了一下解决方法,有人提出了采用物化视图可以解决这个问题。物化视图唯一的缺陷在于同步机制的问题,如果同步时间设置过短,则占用大量的系统资源,给服务器带来极大的压力;如果设置时间过长,前台用户不可接受。

后来还是AskTom给出了极好的解决方案:使用全局临时表。

SQL
> create global temporary table foo

2
(

3 X BLOB

4
)

5 on commit delete rows;

Table created

SQL
> insert into foo select blobcolumn from remoteTable@dl_remote where rownum = 1;

1 row inserted

SQL
>

插入本地临时表之后,在本地的操作就没有任何问题了。

-- 另外一篇

Oracle官方论坛关于DBLink problem ORA-22992的讨论

我做了一下整理,最终那句是最后的答案,相信不用怎么翻译大家都应该能够看懂说些什么,这一点可是搞IT所必须的。
don't know if this is related, but we were also having a problem that was causing the ORA-22992 error, and the solution turned out to be surprisingly simple. A full day of searching the web didn't turn up this answer, but then one of our DBAs accidentally stumbled over something buried in some Oracle documentation that provided the answer.
We have a database table that contains a couple primary key fields (a varchar and an integer), plus a BLOB that holds Word documents. One of our programs needs to be able to connect to a remote Oracle instance and copy Word documents based on certain primary keys.
Our code first attempted to do that like this:
insert into [local Word doc table] ([key column1], [key column 2], [blob column])
values ('[key 1 literal]', [key 2 literal],
(select [blob column] from [Word doc table]@[remote instance]
where [keys = remote keys])
Attempting to execute that was giving us the "cannot use LOB locators selected from remote tables" error.
The documentation that our DBA turned up included a bunch of SQL examples of using remote BLOBs which he thought would be helpful. But what provided the solution was the sentence following the SQL examples: "In statements structured like the preceding examples, only standalone LOB columns are allowed in the select list".
I took that to mean that if you're going to access a BLOB on a remote database, then that BLOB column has to be the ONLY column you're referencing. So I broke our program's SQL up into this:
insert into [local Word doc table] ([key 1 col], [key 2 col], [blob col]) values
('[key 1]', [key 2], NULL)
update [local Word doc table] set [blob col] =
(select [blob col] from [Word doc table]@[remote instance]
where [keys = remote keys])
where [keys = local keys]
I was amazed to find that the above works like a charm. We've got a 100 meg Word document going from one Oracle instance to the other with no problem.
Since doing a Google search on "cannot use LOB locators selected from remote tables" turns this page up near the top of its list of links, I'm hoping that by posting this I can save another programmer somewhere the two or three days of banging your head against the screen that I just went though.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Oracle是当今各领域中应用比较广泛的一个大型关系型数据库产品,它以其所拥有的稳定、可伸缩性强以及安全可靠等特性受到越来越多的系统开发人员的青睐,正成为企业开发信息系统的首选产品。同其他数据库管理系统相比,Oracle产品较为庞大而复杂,因此,令许多数据库管理系统的学习者在Oracle面前止步不前,究其原因,主要是无法掌握Oracle技术的脉络。本书正是根据作者在高校和各种数据库培训班执教多年的教学经验,结合开发应用Oracle数据库的实践经验编撰而成的,书中编排的内容次序非常适合于读者学习和把握Oracle的脉络,书中所选择的问题都是在实际开发应用Oracle过程中经常遇到和所要解决的。通过学习解决这些问题的方法,可以使读者比较深入地认识和掌握Oracle技术的内涵,快速地进入开发角色。本书共分11章。第1章Oracle的安装卸载与使用环境,主要包括Oracle安装环境及方法,安装后的基本环境及服务,Oracle卸载,还包括验证数据库的安装,系统临时空间不足、监听服务无法启动以及Oracle默认帐户/口令等问题的精讲。第2章 Oracle体系结构,包括Oracle数据库逻辑结构和数据库物理结构以及Oracle文件的目录结构等。在案例精讲中对数据块校验、的移动、数据文件丢失或损坏、丢失控制文件、数据文件更名以及数据库内文件的复制传输等问题的解决做了全面细致的讲解。第3章SQL及PL/SQL的运行环境及其他开发工具。第4章 Oracle数据字典管理与数据类型。包括数据字典的分类、使用方法以及各种对象的具体查询等做了详细的介绍。第5章 数据库对象的创建与使用。主要包括各种类型的创建以及适用情形,如外部、分区、嵌套、全局临时等;完整性约束的管理;索引,包括B树索引、基于函数的索引、位图索引、反向索引、降序索引、压缩索引等的使用方法及其适用情形等。在案例精讲中,对压缩、约束的使能与失能、的层次结构查询、防止删除及对象、提取创建外键约束的脚本以及在线重新定义结构的方法做了详细讲解。第6章 PL/SQL程序设计。介绍了PL/SQL中常用的函数、异常处理等,还有对随机数生成、分析函数、多合并、多插入等问题的解决方法。第7章 子程序和触发器,包括函数、存储过程、包以及触发器等。对子程序的调用者权限、管道函数、传递触发器标识:new和:old以及自治事务也给出了具体的解决方法。第8 章 LOB与面向对象的数据管理. 第9章 Oracle的监听器和网络设置。包括Oracle网络体系结构,Oracle Net参数文件的管理,监听器与网络连接配置等。针对应用中经常出现问题,如保护与设置监听器,监听器远程管理,端口号,客户机与服务器的连接,外部过程调用,不能解析服务名以及没有监听器等都给出了详细的解决方法。第10章 数据库管理,包括导出数据库模式的DDL脚本,管理Oracle数据库实例的方法、数据恢复与Flashback以及更改数据库字符集等具体方法。第11章 数据库的安全管理。包括加密Oracle子程序,存储应用程序用户名和口令,禁止修改删除数据库对象,Oracle数据加密以及丢失SYSMAN及资料档案库用户口令的解决方法。书中给出了丰富的图,多数图例是作者根据多年实践总结出来的,图示简练准确,易于理解,并附有解决问题的具体步骤方法和相应的脚本。读者对象:面向各种培训班学员,高校相关专业的学生, Oracle应用开发人员以及Oracle数据库的学习者。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值