Skip to content

Instantly share code, notes, and snippets.

@baybatu baybatu/plsql-upsert.sql
Last active Apr 27, 2016

Embed
What would you like to do?
Upsert example in PL/SQL
-- 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
You can’t perform that action at this time.