Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Insert or update in one SQL statement

Status
Not open for further replies.

Tve

Programmer
May 22, 2000
166
FR
Hi,

I'm not a whiz in SQL, so please forgive my question if it is way out of line, but here goes:

I'm looking for a way to update a record in an Oracle table if it already exists, else to insert it as new record.

I'm currently first running a select statement with a where condition to see if the record exists: if it does, I concatenate a UPDATE statement, and if it doesn't I concatenate a INSERT statement.

It would be nice if I could do this in one statement, something like "UPDATE OR INSERT...." and skip the select statement.

Would this be possible?
AD AUGUSTA PER ANGUSTA

Thierry
 
if you are using SQL embedded within another language then this is achievable using an IF statement to test the return code of the update or insert, otherwise I am not sure it can be done.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top