• Post Reply Bookmark Topic Watch Topic
  • New Topic

Checking existence query?

 
Mr. C Lamont Gilbert
Ranch Hand
Posts: 1170
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
All I want to know is if Name is not null. I have a unique constraint on my name so I need to ensure none exists which is the same as the one I plan to use.

I am using


and rs.next() to tell me if such a name exists or not. Is there a better query for this since I am not even looking at the returned name, only if it exists or not.
 
Jeanne Boyarsky
author & internet detective
Sheriff
Posts: 36031
432
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This version is slightly more efficient because the database doesn't have to return as much data.


Did you want a unique name in general or per component id? The unique index would do it for name only.
 
Gravity is a harsh mistress. But this tiny ad is pretty easy to deal with:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!