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 기반 앱

AI Clothes Remover
사진에서 옷을 제거하는 온라인 AI 도구입니다.

Undress AI Tool
무료로 이미지를 벗다

Clothoff.io
AI 옷 제거제

AI Hentai Generator
AI Hentai를 무료로 생성하십시오.

인기 기사

뜨거운 도구

메모장++7.3.1
사용하기 쉬운 무료 코드 편집기

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

스튜디오 13.0.1 보내기
강력한 PHP 통합 개발 환경

드림위버 CS6
시각적 웹 개발 도구

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

뜨거운 주제











이 기사는 MySQL의 Alter Table 문을 사용하여 열 추가/드롭 테이블/열 변경 및 열 데이터 유형 변경을 포함하여 테이블을 수정하는 것에 대해 설명합니다.

기사는 인증서 생성 및 확인을 포함하여 MySQL에 대한 SSL/TLS 암호화 구성에 대해 설명합니다. 주요 문제는 자체 서명 인증서의 보안 영향을 사용하는 것입니다. [문자 수 : 159]

기사는 MySQL Workbench 및 Phpmyadmin과 같은 인기있는 MySQL GUI 도구에 대해 논의하여 초보자 및 고급 사용자를위한 기능과 적합성을 비교합니다. [159 자].

기사는 MySQL에서 파티셔닝, 샤딩, 인덱싱 및 쿼리 최적화를 포함하여 대규모 데이터 세트를 처리하기위한 전략에 대해 설명합니다.

InnoDB의 전체 텍스트 검색 기능은 매우 강력하여 데이터베이스 쿼리 효율성과 대량의 텍스트 데이터를 처리 할 수있는 능력을 크게 향상시킬 수 있습니다. 1) InnoDB는 기본 및 고급 검색 쿼리를 지원하는 역 색인화를 통해 전체 텍스트 검색을 구현합니다. 2) 매치 및 키워드를 사용하여 검색, 부울 모드 및 문구 검색을 지원합니다. 3) 최적화 방법에는 워드 세분화 기술 사용, 인덱스의 주기적 재건 및 캐시 크기 조정, 성능과 정확도를 향상시키는 것이 포함됩니다.

이 기사에서는 Drop Table 문을 사용하여 MySQL에서 테이블을 떨어 뜨리는 것에 대해 설명하여 예방 조치와 위험을 강조합니다. 백업 없이는 행동이 돌이킬 수 없으며 복구 방법 및 잠재적 생산 환경 위험을 상세하게합니다.

기사는 외국 열쇠를 사용하여 데이터베이스의 관계를 나타내고 모범 사례, 데이터 무결성 및 피할 수있는 일반적인 함정에 중점을 둡니다.

이 기사에서는 PostgreSQL, MySQL 및 MongoDB와 같은 다양한 데이터베이스에서 JSON 열에서 인덱스를 작성하여 쿼리 성능을 향상시킵니다. 특정 JSON 경로를 인덱싱하는 구문 및 이점을 설명하고 지원되는 데이터베이스 시스템을 나열합니다.
