This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
Hi. If a user keys in a postal code that is not in the table, I want an error message to come back stating this. My problem is that I can't seem to figure out how to tell if my select statement didn't find anything. Is there a method I can use that is sort of like a getRowCount? I've tried comparing to null, but that doesn't work. I've also tried comparing the row to zero, but that doesn't get the job done either. Any help is appreciated!! Thanks in advance!
Jennifer If all you want to know is if the number they enter is in the table then try this: SELECT count(*) FROM table WHERE zipcodeColumn = 'userValue' That should just return an integer in the count field that you can check to see if it greater than zero. Either way you do it you should be getting a ResultSet back then just use next to see if there is a row or not. But I know you know that so I might not be understanding your question correctly. Another option would be to turn it into an update and not really do anything in the update: UPDATE table SET zipcodeColumn = 'userValue' WHERE zipcodeColumn = 'userValue' That should still return an update number even if it really doesn't do anything - but that might be kind of dangerous too if the user does something strange. Hope that helps a little bit Dave
Jennifer, If i were u and understood ur problem(U want to check whether the entered number which is a zipcode is valid or not) use the zipcode as a type table and cache it then i dont have to go to database everytime to check it, if it does exist and then only goahead and do rest of the processing this way i will not be tying up the precious system resources. Sorry for not giving a quick answer but for quick fix Bill suggestion is good Kareem
Joined: Mar 14, 2002
I meant Bear B not bill kareem
Joined: Feb 28, 2001
Thanks for the help guys! I appreciate it!
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com