Merge With Condition On Remote Database Returns Wrong Results. (Doc ID 1237913.1)

Last updated on SEPTEMBER 04, 2015

Applies to:

Oracle Database - Enterprise Edition - Version 11.1.0.7 and later
Information in this document applies to any platform.

Symptoms


Merge with condition on remote database return incorrect results.

Test case :
-------------

--on SITEA:
create table test1 (name varchar2(10), id number, price number);

insert into test1 values ( 'aa', 1, 100);
insert into test1 values ( 'bb', 2, 200);

--On SITEB
create table test (name varchar2(10), id number, price number);

insert into test values ( 'xx', 2, 800);

merge into test1@sitea a using test b on (a.id=b.id)
when matched then
update set a.name = b.name where a.price != b.price
when not matched then
insert (name, id, price) values (b.name, b.id, b.price); 2 3 4 5

0 rows merged.

SQL> select * from test1@sitea;

NAME ID PRICE
---------- ---------- ----------
aa 1 100
bb 2 200

SQL> rollback;

Rollback complete.

SQL> select * from test1@rep11a;

NAME ID PRICE
---------- ---------- ----------
aa 1 100
bb 2 200

SQL> select * from test;

NAME ID PRICE
---------- ---------- ----------
xx 2 800

SQL> merge into test1@sitea a using test b on (a.id=b.id)
when matched then
update set a.name = b.name where a.price = b.price
when not matched then
insert (name, id, price) values (b.name, b.id, b.price); 2 3 4 5

1 row merged.

SQL> select * from test1@sitea;

NAME ID PRICE
---------- ---------- ----------
aa 1 100
xx 2 200

SQL> rollback;

Rollback complete.


--on SITEA:

select * from test1;

NAME ID PRICE
---------- ---------- ----------
aa 1 100
bb 2 200

SQL> merge into test1 a using test@siteb b on (a.id=b.id)
when matched then
update set a.name = b.name where a.price != b.price
when not matched then
insert (name, id, price) values (b.name, b.id, b.price); 2 3 4 5

1 row merged.

SQL> select * from test1;

NAME ID PRICE
---------- ---------- ----------
aa 1 100
xx 2 200

SQL> rollback;

Rollback complete.

SQL> select * from test@siteb;

NAME ID PRICE
---------- ---------- ----------
xx 2 800

SQL> merge into test1 a using test@siteb b on (a.id=b.id)
when matched then
update set a.name = b.name where a.price = b.price
when not matched then
insert (name, id, price) values (b.name, b.id, b.price); 2 3 4 5

0 rows merged.

SQL> select * from test1;

NAME ID PRICE
---------- ---------- ----------
aa 1 100
bb 2 200

Cause

Sign In with your My Oracle Support account

Don't have a My Oracle Support account? Click to get started

My Oracle Support provides customers with access to over a
Million Knowledge Articles and hundreds of Community platforms