데이터 베이스 MySQL 튜토리얼 ORA-02055: distributed update operation failed; rollback req

ORA-02055: distributed update operation failed; rollback req

Jun 07, 2016 pm 05:29 PM

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.

linux

본 웹사이트의 성명
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.

뜨거운 기사 태그

메모장++7.3.1

메모장++7.3.1

사용하기 쉬운 무료 코드 편집기

SublimeText3 중국어 버전

SublimeText3 중국어 버전

중국어 버전, 사용하기 매우 쉽습니다.

스튜디오 13.0.1 보내기

스튜디오 13.0.1 보내기

강력한 PHP 통합 개발 환경

드림위버 CS6

드림위버 CS6

시각적 웹 개발 도구

SublimeText3 Mac 버전

SublimeText3 Mac 버전

신 수준의 코드 편집 소프트웨어(SublimeText3)

Docker에서 MySQL 메모리 사용을 줄입니다 Docker에서 MySQL 메모리 사용을 줄입니다 Mar 04, 2025 pm 03:52 PM

Docker에서 MySQL 메모리 사용을 줄입니다

Alter Table 문을 사용하여 MySQL에서 테이블을 어떻게 변경합니까? Alter Table 문을 사용하여 MySQL에서 테이블을 어떻게 변경합니까? Mar 19, 2025 pm 03:51 PM

Alter Table 문을 사용하여 MySQL에서 테이블을 어떻게 변경합니까?

MySQL의 문제를 해결하는 방법 공유 라이브러리를 열 수 없습니다. MySQL의 문제를 해결하는 방법 공유 라이브러리를 열 수 없습니다. Mar 04, 2025 pm 04:01 PM

MySQL의 문제를 해결하는 방법 공유 라이브러리를 열 수 없습니다.

Linux에서 MySQL을 실행합니다 (Phpmyadmin이있는 Podman 컨테이너가 포함되지 않음) Linux에서 MySQL을 실행합니다 (Phpmyadmin이있는 Podman 컨테이너가 포함되지 않음) Mar 04, 2025 pm 03:54 PM

Linux에서 MySQL을 실행합니다 (Phpmyadmin이있는 Podman 컨테이너가 포함되지 않음)

sqlite 란 무엇입니까? 포괄적 인 개요 sqlite 란 무엇입니까? 포괄적 인 개요 Mar 04, 2025 pm 03:55 PM

sqlite 란 무엇입니까? 포괄적 인 개요

MacOS에서 여러 MySQL 버전을 실행 : 단계별 가이드 MacOS에서 여러 MySQL 버전을 실행 : 단계별 가이드 Mar 04, 2025 pm 03:49 PM

MacOS에서 여러 MySQL 버전을 실행 : 단계별 가이드

인기있는 MySQL GUI 도구는 무엇입니까 (예 : MySQL Workbench, Phpmyadmin)? 인기있는 MySQL GUI 도구는 무엇입니까 (예 : MySQL Workbench, Phpmyadmin)? Mar 21, 2025 pm 06:28 PM

인기있는 MySQL GUI 도구는 무엇입니까 (예 : MySQL Workbench, Phpmyadmin)?

MySQL 연결에 대한 SSL/TLS 암호화를 어떻게 구성합니까? MySQL 연결에 대한 SSL/TLS 암호화를 어떻게 구성합니까? Mar 18, 2025 pm 12:01 PM

MySQL 연결에 대한 SSL/TLS 암호화를 어떻게 구성합니까?

See all articles