Logo 
Search:

Java Answers

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds
  Question Asked By: Grant Young   on Oct 10 In Java Category.

  
Question Answered By: Christie Bradley   on Oct 10

You can concatenate the Query string  based on the condition whether the
parameter is null  or not


public SearchQuery[] getSearchResult(String rxm_number, String
facility, String upload_date, String comments, String document_desc,
String archive, String document,String document_seq) {

String strQuery = "select * from tablename where ";


if (rxm_number !="")
{
strQuery = strQuery + " rxm_number = '" + rxm_number +"' and";
}

if (facility!="")
{
strQuery = strQuery + " facility = '" + facility + "' and";
}
//like that u can add dynamically based on the condition..
//Take care on 'and '

}

Share: 

 

This Question has 9 more answer(s). View Complete Question Thread

 
Didn't find what you were looking for? Find more on Problem in Fetching Values Or get search suggestion and latest updates.


Tagged: