I am getting an ORA-30926 error. I researched this and found that this is usually caused by duplicates in the query specified in theUSING
clause.
The problem is I am intially removing duplicates and storing in a temperory table (temp_distinct
) which in turn I am referring to in the MERGE
. Here is my code snippet:
MERGE INTO name_test nt
USING (select name from temp_distinct) s
ON (1=1)
WHEN MATCHED
THEN UPDATE SET nt.fn = s.name, nt.LN = s.name
Here is the structure of my tables:
NAME_TEST
:
FN LN
----- -----
Ruc Rag
Ruc Ran
Sam Kum
Ruc Ran
Ruc Kum
Ran Dev
Rag Agar
Rag Ran
TEMP_DISTINCT
:
FN NUMB NAME NUM
----- ---- ----- ---
Sam 1 Mark 1
Rag 2 Steve 2
Dev 3 John 3
Kum 4 Dave 4
Ruc 5 Mich 5
Agar 6 Dean 6
Ran 7 Phil 7
So as you can see there is no duplicate in USING
clause. I am trying to replace NT.FN = S.NAME
and also NT.LN = S.NAME
.
Basically I want to replace names in FN
and LN
from NAME_TEST
table with different name from TEMP_DISTINCT
table. Final output should be like below:
FN LN
------ ------
Mich Steve
Mich Phil
Mark Dave
Mich Phil
Mich Dave
Phil John
Steve Dean
Steve Ran