2

I can't seem to find what's missing in my query :

MERGE INTO Account D
   USING (SELECT       1 AS ID 
                 ,'AAAA' AS NAME
                ,'123Z4' AS GUID
                     , 1 AS STATUS 
          FROM DUAL
         ) S
   ON (D.GUID  = S.GUID)
   AND (D.Name = S.Name)
   WHEN MATCHED 
   THEN 
   UPDATE SET D.Status = S.Status 
   WHEN NOT MATCHED 
   THEN 
   INSERT (D.Id, D.Name, D.GUID, D.Status)
   VALUES (1 , 'AAAA' , '123Z4' , 1)

It gives me an error of ORA-00905: missing keyword.

Nomade
  • 1,760
  • 2
  • 18
  • 33
Jay
  • 21
  • 2
  • 5
    I think the join condition needs to be in a single pair of parentheses: `ON (D.GUID = S.GUID AND D.Name = S.Name)` –  Feb 23 '18 at 08:56
  • Darn, it worked! Thank you so much!, Sorry that never came up in my mind. – Jay Feb 23 '18 at 09:12

1 Answers1

0

The join condition between the target table and the source query needs to be a "single" condition inside one pair of parentheses:

ON (D.GUID  = S.GUID AND D.Name = S.Name)