File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JDBC and the fly likes oracle equivalent to  Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "oracle equivalent to  "IF EXISTS"" Watch "oracle equivalent to  "IF EXISTS"" New topic
Author

oracle equivalent to "IF EXISTS"

g forte
Greenhorn

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
or
IF EXISTS?

TIA!!
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 29249
    
139

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


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: oracle equivalent to "IF EXISTS"
 
Similar Threads
NX: DuplicateKeyException for records without keys!? *blink*
using hibernate formula
BatchUpdateException .UpdateCounts
exception
SQL query????