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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

java select statement

Status
Not open for further replies.

simanek

Programmer
Jan 19, 2001
137
US
Hi all,

I'm trying to insert a value into a table but I want to make sure that it is a unique value. So what I'm doing is performing a select statement first but it is faulting saying that there was 'no data read'. When the select is through, I would compare it to "NULL" but I can't since it faults before this. I'm doing this in java and having a helluva time doing it. Any help is appreciated.

Mike Mike
~~~~
simanek@uiuc.edu
"It's a Swingline!"
~~~~
 
Unique key is normally used to check field uniquness.
The reason is that your session may check for uniqueness while another session is doing the same. So both get the same positive result, but after inserting the field will not be unique. As for your program - catch this exception, because it's raised to let you know that NO DATA returned by your query and the value you're checking for does not exist in table yet.
If you still want to comppare the result with null you may use some grouping function (max, min, sum). They normally return NULL on empty set.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top