Personal tools
You are here: Home DB2 How To's How to use the merge command to update and insert data from and into the same table
Navigation
Log in


Forgot your password?
 
Document Actions

How to use the merge command to update and insert data from and into the same table

How to use the merge command to update and insert data from and into the same table? Merge variant: Automerge!

MERGE INTO MYTABLE AS A
USING (VALUES (1, 'ABCD')) AS A_TMP (ID, NAME)
ON A.ID = A_TMP.ID
WHEN MATCHED THEN
    UPDATE SET NAME = 'EFGH'
WHEN NOT MATCHED THEN
    INSERT (ID, NAME) VALUES (A_TMP.ID, A_TMP.NAME)
ELSE IGNORE;
Security Awareness
Would you like your company to implement gamification into your security awareness program?





Polls