jQuery in Action, 3rd edition
The moose likes JDBC and Relational Databases and the fly likes oracle equivalent to  Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "oracle equivalent to  "IF EXISTS"" Watch "oracle equivalent to  "IF EXISTS"" New topic

oracle equivalent to "IF EXISTS"

g forte

Joined: Aug 28, 2003
Posts: 25
Hello all,
I am trying to write a query that will check if a record exists and, if not , inserts the record in 1 trip to the db.
I have this query:

IF NOT EXISTS (Select award_number from hold_table_award WHERE award_number = 'duh') BEGIN INSERT INTO hold_table_award(award, title)VALUES(?,?)

This wont work in Oracle.
Anyone know how to make it work or if Oracle has something similar to IF NOT EXISTS

Jeanne Boyarsky
author & internet detective

Joined: May 26, 2003
Posts: 32819

You can definitely use a stored procedure. I'm not sure of a way to do it using raw SQL.

[OCA 8 book] [Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2
I agree. Here's the link: http://aspose.com/file-tools
subject: oracle equivalent to "IF EXISTS"
jQuery in Action, 3rd edition