Jump to content
We've recently updated our Privacy Statement, available here ×

How do we write conditional query in Ireport query executer


ashcsi1322

Recommended Posts

  • Replies 5
  • Created
  • Last Reply

Top Posters In This Topic

Hi,

You can do this by simply using the following:

Suppose there is a parameter called $P{TestParamSQL}, the prompt should be turned off as we are setting the value at runtime checking the value of the $P{TEST_PARAM}. 

Set the default value of the parameter as:

For a single condition 

$P{TEST_PARAM}.equals("test")? " select SQL query": " else SQL select query"[/code]

For a multiple condition 

 

$P{TEST_PARAM}.equals("test")? " select SQL query": $P{TEST_PARAM}.equals("test1")? " SQL select query": $P{TEST_PARAM}.equals("test2")?" SQL Query": "else SQL Query"[/code]

 

Now in the iReport Query executor you should give the following expression
$P!{TestParamSQL}
 

Do take care that the dependent parameter $P{TEST_PARAM}. should be set before the $P{TestParamSQL} else would throw a null pointer exception.

Another thing which should be kept in mind is that the query given in the quotes in the expression should be syntactically correct, that is the SQL in as the string should be correct.

Hope that this helps.

 

Thanks,
Ankur Gupta

 

Link to comment
Share on other sites

  • 4 weeks later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...