Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

oracle equivalent to "IF EXISTS"

 
g forte
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
author & internet detective
Marshal
Posts: 34372
345
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can definitely use a stored procedure. I'm not sure of a way to do it using raw SQL.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic