解决:ORA-02064 distributed operation not supported

5 篇文章 0 订阅

起因:
近日项目需要通过Oracle DBLink调用远程数据库的存储过程。
即:数据库A ,B 通过DBlink互相访问, 数据库A调用数据库B的存储过程pro_b , pro_b里面有DML语句,且有commit ,或rollback. 这时数据库A通过DBlink 的调用pro_b@B就会产生这个错误:
Caused by: java.sql.SQLException: ORA-02064: distributed operation not supported

原因:
查询了一下oracle文档,对于这个错误的描述如下:

ORA-02064 distributed operation not supported
Cause:One of the following unsupported operations was attempted:
Array execute of a remote update with a subquery that references a database link, or
An update of a long column with bind variable and an update of a second column with a subquery that both references a database link and a bind variable, or
A commit is issued in a coordinated session from an RPC with OUT parameters.
Action:Simplify the remote update statement.

数据库A通过Oracle DBLink到另一个数据库B,调用了对方(B)的存储过程时,如果该存储过程中有更新(DDL)数据的操作,则会有ora-02064不支持分布式

解决方法:
在不修改数据库B,pro_b的业务逻辑的情况下有两种方法可以解决:

1.在被调的存储过程(pro_b)中,增加一个传入参数,且增加判断逻辑,如果来自数据库A的调用则不要commit,rollback数据库事务操作,如果是来自本地的调用继续沿用之前的逻辑。

2.用Oracle自治事务来解决。在数据库A中的procedure中添加oralce自治事务的声明方法为:
PRAGMA AUTONOMOUS_TRANSACTION。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值