Shekhar
Shekhar

Reputation: 11788

Insert ...on duplicate in oracle?

I am new to Oracle and I want to check if particular primary key value is present or not. If value exists then just update the entire row .If value is not present, then insert new row.

INSERT INTO table (a,b,c) VALUES (1,2,3)
  ON DUPLICATE KEY UPDATE c=c+1;

Code above works on MySql. How to achieve the same in Oracle 10g? Can anyone please help?

Upvotes: 0

Views: 2016

Answers (1)

Jonathan Leffler
Jonathan Leffler

Reputation: 753675

Look up the SQL standard MERGE statement, which is supported by (more recent versions of) Oracle. This will work with other DBMS than Oracle too.

Upvotes: 2

Related Questions