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 Ignoring SQL parameters Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Databases » JDBC
Reply Bookmark "Ignoring SQL parameters" Watch "Ignoring SQL parameters" New topic
Author

Ignoring SQL parameters

Nick Potter
Ranch Hand

Joined: May 07, 2008
Posts: 125
Hello,

I have this statement for example:

SELECT * FROM mytable WHERE col1='val1' AND col2='val2';

one of the parameters could be null and in this case i'd like it ignored. How can i do this without using ifs, since in the code i actually have 7 parameters and it's a hassle to check if every parameter is null;

Thanks
Jan Cumps
Bartender

Joined: Dec 20, 2006
Posts: 2343

i actually have 7 parameters and it's a hassle to check if every parameter is nul
I'm afraid that you will have to go through the hassle. How would you resolve this without checking it in your code, and dynamically creating the sql statement?


OCUP UML fundamental
ITIL foundation
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Ignoring SQL parameters
 
Similar Threads
What is the output ?
A method with many parameters.........
Session problem or the browser problem?
CXF 2.2 @FormParam - Not working?
doPost how to get parameters ?