I dit tilfælde behøver du ikke bruge delen:
WHEN MATCHED THEN UPDATE ...
( ved at bruge WHEN MATCHED THEN UPDATE SET a.id = a.id
er accepteret (Oracle kaster ikke), men har ingen indflydelse, så en sådan brug er overflødig, fordi du ikke ønsker at ændre noget for den matchende sag. )
Fortsæt med følgende for den aktuelle sag:
SQL> CREATE TABLE domains(
id INT,
name VARCHAR2(50),
code VARCHAR2(50),
description VARCHAR2(50)
);
SQL> INSERT INTO domains VALUES(1,'Domain A','D.A.','This is Domain A');
SQL> MERGE INTO domains A USING
(SELECT 2 id, 'Domain A' name, 'D.A.' code, 'This is Domain A' description
FROM domains) b
ON ( a.name = b.name )
WHEN NOT MATCHED THEN INSERT( a.id, a.name, a.code, a.description )
VALUES( b.id, b.name, b.code, b.description );
SQL> SELECT * FROM domains;
ID NAME CODE DESCRIPTION
-- -------- ----- ----------------
1 Domain A D.A. This is Domain A
SQL> DELETE domains;
SQL> INSERT INTO domains VALUES(1,'Domain A','D.A.','This is Domain A');
-- we're deleting and inserting the same row again
SQL> MERGE INTO domains A USING
(SELECT 2 id, 'Domain B' name, 'D.B.' code, 'This is Domain B' description
FROM domains) b
ON ( a.name = b.name )
WHEN NOT MATCHED THEN INSERT( a.id, a.name, a.code, a.description )
VALUES( b.id, b.name, b.code, b.description );
SQL> SELECT * FROM domains;
ID NAME CODE DESCRIPTION
-- -------- ----- ----------------
1 Domain A D.A. This is Domain A
2 Domain B D.B. This is Domain B