ORA-02064 distributed operation not supported

http://space.itpub.net/471666/viewspace-207344

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 ,B 通过DBlink互相访问, 数据库A 调用数据库B的存储过程pro_b , pro_b 过程中有out 输出参数,并且里面有dml语句,之后commit ,或rollback. 这时数据库A 通过DBlink 的调用pro_b@B就会产生这个错误.

解决办法:

1. 去掉pro_b中的commit, rollback ,统一有数据库B来控制事务.(当然也可以去掉out参数,这样也破坏是事务的完整性)

2.用自制事务来控制pro_b , 在pro_b中添加.PRAGMA AUTONOMOUS_TRANSACTION; 优点:不用去修改调用的所有方法.当然这样也不能控制事务的完整.

http://jordan1226.itpub.net/post/989/459566

今天,开发人员在调用远端数据库的过程truncate表的时候,oracle提示 ORA-02064,

查询了一下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.

我们业务的实现: 过DBLINK调用远程数据库的存储过程,进行TRUNCATE TABLE,并返回成功与否的标志。

根据oracle文档的描述,问题应该出在返回标志的问题上,我试了一下,如果,不用返回参数的时候,过程可以成功执行,如果加上返回参数,则提示ORA-02064

应该是oracle认为远程调用过程,执行和返回标志是一个完整的事务,如果要返回到远端,那么就破坏了事务的完整性,所以提示ORA-02064

这个问题的解决办法有两个:1.不要返回标志,根据过程是否成功执行,在本地做判断,2.在远端的过程中加入 PRAGMA AUTONOMOUS_TRANSACTION; 这句话,制定义事务.

修改后的过程,如下

CREATE OR REPLACE PROCEDURE P_EXECUTE_DDL(AN_O_RET_CODE OUT NUMBER,
AC_O_RET_MSG OUT VARCHAR2,
AC_I_DDL IN VARCHAR2) IS
/******************************************************************
项目名称:E_SIM6.0
所属用户:EA_CGYW
概要说明:
中文名称:提供远程数据库(进行DDL操作)调用
语法信息:
用途简述:提供远程数据库(进行DDL操作)调用
输入参数:
输出参数:
调用举例:
VARIABLE AN_O_RET_CODE NUMBER;
VARIABLE AC_O_RET_MSG VARCHAR2;
EXEC P_EXECUTE_DDL(:AN_O_RET_CODE,:AC_O_RET_MSG,'TRUNCATE TABLE TABLE_NAME');
功能修订:
简要说明:

修订记录:
修订日期 修订人 修改内容简要说明
---------- ---------- ------------------------------

******************************************************************/
PRAGMA AUTONOMOUS_TRANSACTION;
BEGIN
AC_O_RET_MSG := '操作成功';
AN_O_RET_CODE := 0;

EXECUTE IMMEDIATE AC_I_DDL;

EXCEPTION
WHEN OTHERS THEN
ROLLBACK;
AN_O_RET_CODE := -1;
AC_O_RET_MSG := '错误代码:' || SQLCODE || CHR(13) || '错误信息:' || SQLERRM;
END P_EXECUTE_DDL;

这样就可以远程调用了,清空远程的表了.

在这里要感谢 蜗牛,songsong 对本人的支持,非常感谢,让我又学到了一招:)!!!!!!!!

转载于:https://www.cnblogs.com/NickyYe/archive/2012/01/16/2323369.html

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值