I face a problem with the following query:
merge into table2 d
using (
select firstname, lastname, max(id) id
from table1 t1
group by firstname, lastname
having count(0) = 1
) s
on (d.firstname=s.firstname and d.lastname=s.lastname)
when matched then update set t1_id = s.id;
If multiple rows in table2 match the ON clause, then I get "SQL Error: ORA-30926: unable to get a stable set of rows in the source tables"
Do you know any way to filter and just ignore those "duplicates"? Thanks.
EDIT
@Polppan, your request for sample data has lead me on a very strange way:
here some sample data:
table1
ID firstname lastname
1 John Doe
2 John DOE
3 Jane Doe
4 Jane Doe
(notice the UPPER)
table2
t1_ID firstname lastname
null John Doe
null Jane Doe
null Jane Doe
now, I couldn't reproduce the error with those data until:
- the ON clause is "UPPER(d.firstname)=UPPER(s.firstname) AND UPPER(d.lastname)=UPPER(s.lastname)" (which is what I have since I need case-insensitive matching)
- one of the lines in table1 has DOE in uppercase
Any idea why?