Skip to content

Instantly share code, notes, and snippets.

@klashxx
Last active November 21, 2016 16:13
Show Gist options
  • Save klashxx/03b2a822e7846c8308d0 to your computer and use it in GitHub Desktop.
Save klashxx/03b2a822e7846c8308d0 to your computer and use it in GitHub Desktop.
MERGE example (oracle)
MERGE INTO tab D
USING (SELECT 99999 as id_c1,
SYSDATE as c2,
'klashxx' as c3,
'test' as c4,
'test' as c5,
'test' as c6,
'not_matched' as c7
FROM DUAL) S
ON (D.id_c1 = S.id_c1)
WHEN MATCHED THEN
UPDATE SET D.c7 = 'matched'
WHEN NOT MATCHED THEN
INSERT VALUES (S.id_c1, S.c2, s.c3, s.c4, s.c5, s.c6, s.c7);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment