web analytics

[Solved] ORA-30926: unable to get a stable set of rows in the source

Options

renaudj 2 - 93
@2016-02-16 13:59:53
SQL> create table target(id number, name varchar2(10));

Table created.

SQL> insert into target values (1, 'karthick');

1 row created.

SQL> commit;

Commit complete.

SQL> create table source(id number, name varchar2(10));

Table created.

SQL> insert into source values (1, 'sql');

1 row created.

SQL> insert into source values (1, 'oracle');

1 row created.

SQL> commit;

Commit complete.

SQL> select * from target;

        ID NAME
---------- ----------
         1 karthick

SQL> select * from source;

        ID NAME
---------- ----------
         1 sql
         1 oracle

SQL> merge into target t
using (select * from source) s  
  on (t.id = s.id)
when matched then update set t.name = s.name;  2    3    4  
merge into target t
           *
ERROR at line 1:
ORA-30926: unable to get a stable set of rows in the source tables
@2016-02-16 14:08:00

This error occurs when the query in the using clause returns more than 1 row for the joining condition
in on clause.
ORA-30926: unable to get a stable set of rows in the source tables

Cause: A stable set of rows could not be got because of large dml activity
or a non-deterministic where clause.

Action: Remove any non-deterministic where clauses and reissue the dml.

To solve above issue, make id column as the primary key in the table source.

create table source(id number not null,
 		    name varchar2(10) null,
    CONSTRAINT    pk_source   PRIMARY KEY (id));

merge into target t
using (select * from source) s 
  on (t.id = s.id)
when matched then update set t.name = s.name;

Comments

You must Sign In to comment on this topic.


© 2024 Digcode.com