[转帖]ORA-02046: 分布式事务处理已经开始解决方案_MySQL, Oracle及数据库讨论区_Weblogic技术|Tuxedo技术|中间件技术|Oracle论坛|JAVA论坛|Linux/Unix技术|hadoop论坛_联动北方技术论坛  
网站首页 | 关于我们 | 服务中心 | 经验交流 | 公司荣誉 | 成功案例 | 合作伙伴 | 联系我们 |
联动北方-国内领先的云技术服务提供商
»  游客             当前位置:  论坛首页 »  自由讨论区 »  MySQL, Oracle及数据库讨论区 »
总帖数
2
每页帖数
101/1页1
返回列表
0
发起投票  发起投票 发新帖子
查看: 2787 | 回复: 1   主题: [转帖]ORA-02046: 分布式事务处理已经开始解决方案        上一篇   下一篇 
Kapotthpep
注册用户
等级:新兵
经验:66
发帖:2
精华:0
注册:2018-10-9
状态:离线
发送短消息息给Kapotthpep 加好友    发送短消息息给Kapotthpep 发消息
发表于: IP:您无权察看 2019-9-12 15:52:35 | [全部帖] [楼主帖] 楼主

业务场景:A库上的数据同步到B库上,这个本来是很简单的问题,但由于要在B库上建表,A库只能通过调用B库的存储过程才能实现,就这样就报错了,错误如下:

ORA-02046: 分布式事务处理已经开始

ORA-02063: 紧接着 line (起自 DBLINK_TO_GD)

ORA-06512: 在 "LC_SC_DBLINK_TEST.PKG_SP_ETL_DBLINK_SOUR", line 253

[oracle@oracle ~]$ oerr ora 20463
02046, 00000, "distributed transaction already begun"
// *Cause: internal error or error in external transaction manager.
//         A server session received a begin_tran RPC before finishing
//         with a previous distributed tran.


 在远程调用的存储过程或者包中使用事务控制语句。因为远程调用的包执行时没有机制执行2-phase commit。事务控制语句应该在发起事务的节点执行。

解决方案:

        所有的操作在A上执行,可以通过dbms_utility.EXEC_DDL_STATEMENT实现在A上远程DDL,在操作前后都加上。

dbms_session.close_database_link(dblink_name);
exec dbms_utility.EXEC_DDL_STATEMENT@db_link_developer('create table test as select * from dba_objects@dblink_to_A');
--实验参见http://blog.csdn.net/stevendbaguo/article/details/50155845
dbms_session.close_database_link(dblink_name);




赞(0)    操作        顶端 
联动大白
注册用户
等级:列兵
经验:91
发帖:0
精华:0
注册:2015-5-27
状态:离线
发送短消息息给联动大白 加好友    发送短消息息给联动大白 发消息
发表于: IP:您无权察看 2019-10-2 0:30:00 | [全部帖] [楼主帖] 2  楼

为了方便大家阅读,我对文章中错误号来解释一下吧!

Error Id: ORA-06512

Title: at stringline string

Description:

at stringline string

Action:

Fix the problem causing the exception or write an exception handler for this condition. Or you may need to contact your application administrator or DBA.

Cause:

Backtrace message as the stack is unwound by unhandled exceptions.


Error Id: ORA-02063

Title: preceding stringstring from stringstring

Description:

preceding stringstring from stringstring

Action:

refer to the preceding error message(s)

Cause:

an Oracle error was received from a remote database link.


Error Id: ORA-02046

Title: distributed transaction already begun

Description:

distributed transaction already begun

Action:

none

Cause:

internal error or error in external transaction manager. A server session received a begin_tran RPC before finishing with a previous distributed tran.


也许你已明白,但对一个人有用也是我存在的理由!^_^ By:持之以恒的大白

-- 来自: 北京联动北方科技有限公司



赞(0)    操作        顶端 
总帖数
2
每页帖数
101/1页1
返回列表
发新帖子
请输入验证码: 点击刷新验证码
您需要登录后才可以回帖 登录 | 注册
技术讨论