ORA-02055: distributed update operation failed; rollback req
ORA-02055: distributed update operation failed; rollback required
最近同事遇到一个奇怪的问题求助,以下奉上国外大神的问题重现及解决方法
--------------------------------------------------------------
ORA-02055: distributed update operation failed; rollback required
--------------------------------------------------------------
You call a remote procedure or package over a database link.
Now, on the other side (the remote side), there was an error encountered, but there were already some statements executed successfully.
Now you will need to perform a rollback before you can do a select on the calling side, or you will get this error.
原因:通过数据库链接调用远程存储过程或包。然而,执行过程中远程数据库有报错,,但是部分语句已成功执行
措施:在调用端可以查询之前,需要执行回滚操作,否则将获得以上错误提示。
问题重现:
-- First we create some test users
SQL> drop user test1 cascade;
User dropped.
SQL> drop user test2 cascade;
SQL> create user test1 identified by test1;
User created.
SQL> create user test2 identified by test2;
User created.
SQL> grant create session, create table, create trigger, create procedure, create database link to test1, test2;
Grant succeeded.
SQL> alter user test1 quota unlimited on system;
User altered.
SQL> alter user test2 quota unlimited on system;
User altered.
Now we connect to test 2 (remote user) and create a table
SQL> conn test2/test2@XE
Connected.
SQL> create table test2_tab(n number);
Table created.
SQL> insert into test2_tab values(1);
1 row created.
SQL> commit;
Commit complete.
In order to demonstrate this error, we create a trigger on the newly created table, but make sure the trigger fails. In our case, we assign a character to a number field:
create or replace trigger test2_tab_bir
before insert on test2_tab
for each row
begin
:new.n := 'a';
end;
/
Trigger created.
Connect to test1, create database link
SQL> conn test1/test1@XE
Connected.
SQL>
SQL> create database link test2 connect to test2 identified by test2 using 'XE';
Database link created.
Now we will create a procedure which will first do a successful dml, after that a dml that fails due to the incorrect trigger:
create or replace procedure p is
begin
-- first do a statement that executes ok
update test2_tab@test2 set n=2;
-- next statement will fail because of the invalid trigger
insert into test2_tab@test2 values(1);
end;
/
Procedure created.
Call the procedure, it will fail:
SQL> exec p
BEGIN p; END;
*
ERROR at line 1:
ORA-02055: distributed update operation failed; rollback required
ORA-06502: PL/SQL: numeric or value error: character to number conversion error
ORA-06512: at "TEST2.TEST2_TAB_BIR", line 2
ORA-04088: error during execution of trigger 'TEST2.TEST2_TAB_BIR'
ORA-02063: preceding 3 lines from TEST2
ORA-06512: at "TEST1.P", line 4
ORA-06512: at line 1
Now we have a failed distributed transaction, you need to rollback, else you will get the error when selecting ANY table/view
SQL> select sysdate from dual;
select sysdate from dual
*
ERROR at line 1:
ORA-02067: transaction or savepoint rollback required
-- also happens when Oracle itself calls another select recursively (notice the ORA-00604)
SQL> select * from user_2pc_pending;
select * from user_2pc_pending
*
ERROR at line 1:
ORA-00604: error occurred at recursive SQL level 1
ORA-02067: transaction or savepoint rollback required
-----------------------------------
Present By Dylan.

热AI工具

Undresser.AI Undress
人工智能驱动的应用程序,用于创建逼真的裸体照片

AI Clothes Remover
用于从照片中去除衣服的在线人工智能工具。

Undress AI Tool
免费脱衣服图片

Clothoff.io
AI脱衣机

AI Hentai Generator
免费生成ai无尽的。

热门文章

热工具

记事本++7.3.1
好用且免费的代码编辑器

SublimeText3汉化版
中文版,非常好用

禅工作室 13.0.1
功能强大的PHP集成开发环境

Dreamweaver CS6
视觉化网页开发工具

SublimeText3 Mac版
神级代码编辑软件(SublimeText3)

热门话题

本文讨论了使用MySQL的Alter Table语句修改表,包括添加/删除列,重命名表/列以及更改列数据类型。

InnoDB的全文搜索功能非常强大,能够显着提高数据库查询效率和处理大量文本数据的能力。 1)InnoDB通过倒排索引实现全文搜索,支持基本和高级搜索查询。 2)使用MATCH和AGAINST关键字进行搜索,支持布尔模式和短语搜索。 3)优化方法包括使用分词技术、定期重建索引和调整缓存大小,以提升性能和准确性。

文章讨论了为MySQL配置SSL/TLS加密,包括证书生成和验证。主要问题是使用自签名证书的安全含义。[角色计数:159]

文章讨论了流行的MySQL GUI工具,例如MySQL Workbench和PhpMyAdmin,比较了它们对初学者和高级用户的功能和适合性。[159个字符]

本文讨论了使用Drop Table语句在MySQL中放下表,并强调了预防措施和风险。它强调,没有备份,该动作是不可逆转的,详细介绍了恢复方法和潜在的生产环境危害。

本文讨论了在PostgreSQL,MySQL和MongoDB等各个数据库中的JSON列上创建索引,以增强查询性能。它解释了索引特定的JSON路径的语法和好处,并列出了支持的数据库系统。

MySQL支持四种索引类型:B-Tree、Hash、Full-text和Spatial。1.B-Tree索引适用于等值查找、范围查询和排序。2.Hash索引适用于等值查找,但不支持范围查询和排序。3.Full-text索引用于全文搜索,适合处理大量文本数据。4.Spatial索引用于地理空间数据查询,适用于GIS应用。
