Skip to content

Instantly share code, notes, and snippets.

@ran488
Created June 6, 2016 17:42
Show Gist options
  • Save ran488/d4d6a3dce4baeed8d4156c3a0c1752c3 to your computer and use it in GitHub Desktop.
Save ran488/d4d6a3dce4baeed8d4156c3a0c1752c3 to your computer and use it in GitHub Desktop.
Insert into an Oracle table only if it does not already exist (no errors)
-- first SELECT has values you want to insert.
-- second SELECT has enough of those values to verify if record already exists (e.g. primary key)
insert into some_table(col1, col2)
select "value 1", "value 2" from dual where not exists
(select 1 from some_table where col1 = "value 1" and col2 = "value3")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment