当前位置:  数据库>oracle

ORA-02055: distributed update operation failed; rollback required

    来源: 互联网  发布时间:2017-05-21

    本文导语: 最近同事遇到一个奇怪的问题求助,以下奉上国外大神的问题重现及解决方法 -------------------------------------------------------------- ORA-02055: distributed update operation failed; rollback required --------------------------------------------------------------  Y...

最近同事遇到一个奇怪的问题求助,以下奉上国外大神的问题重现及解决方法
 
--------------------------------------------------------------
 
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.


    
 
 

您可能感兴趣的文章:

 
本站(WWW.)旨在分享和传播互联网科技相关的资讯和技术,将尽最大努力为读者提供更好的信息聚合和浏览方式。
本站(WWW.)站内文章除注明原创外,均为转载、整理或搜集自网络。欢迎任何形式的转载,转载请注明出处。












  • 相关文章推荐
  • 出现ORA-01401和ORA-01008错误?
  • Eclipse连接Oracle数据库的ORA-00604 ORA-12705错误
  • oracle ORA-01114、ORA-27067错误解决方法
  • Oracle不能删除表 ORA-00604 ORA-01422 错误
  • 如何得到带有ora的行的下一行
  • ORA-12514及ORA-28547错误解决方案
  • 如何配置 linux 下 oracle 的 listener .ora 和
  • 浅析如何在tnsnames.ora中配置监听
  • Orcle的package中访问其它Schema的表报错ORA-00942解决方法
  • oracle远程连接服务器出现 ORA-12170 TNS:连接超时 解决办法
  • [Oracle] 浅析令人抓狂的ORA-01555问题
  • 解决报错ora-32035的方法分析
  • aq.executeQuery: ORA-00020: maximum number of processes (59) exceeded
  • Oracle 数据库闪回功能设置出现ORA-19809和ORA-19804错误
  • ORA-00947:Not enough values (没有足够的值)的深入分析
  • solaris10 安装 ora9.2.0.1 时报错
  • 在UNIX下,我的ORA817该怎么样才可以自己启动呀?
  • 基于ORA-12170 TNS 连接超时解决办法详解
  • plsql连接oracle数据库报ora 12154错误解决方法
  • 安装oracle出现error:ora-01031:insufficient privilleges的解决


  • 站内导航:


    特别声明:169IT网站部分信息来自互联网,如果侵犯您的权利,请及时告知,本站将立即删除!

    ©2012-2021,