Last active
April 27, 2016 12:58
-
-
Save baybatu/f59b4e70d1cb57417323 to your computer and use it in GitHub Desktop.
Upsert example in PL/SQL
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Insert entity into MY_TABLE table using 'entity_id' and 'name' fields if not exists. | |
-- Otherwise, update row's 'name' field. | |
MERGE INTO MY_TABLE TBL USING dual ON (TBL.entity_id = ?) | |
WHEN NOT MATCHED THEN INSERT (entitiy_id, name) VALUES (?, ?) | |
WHEN MATCHED THEN UPDATE SET TBL.name = ? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment