Jump to content

Dynamic query


fender989100

Recommended Posts

Hi

I have input id param in my report.

If id == null then I need to use a query like this:

SELECT id, name

FROM company

 

But if id == 1 (or another number)

I need to use that query:

SELECT id, name

FROM company WHERE id = 1

I've tried ti create one param that depends from another param, for example:

$P{id} == null ? "WHERE true" : (" WHERE id = " + $P{id})

but it's not working, the resuls is always "WHERE true"

 

Is that possible to do?

Link to comment
Share on other sites

  • Replies 4
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

Hi,
Then I guess the issue is not with the conditional parameter. There may be an issue with passing the parameter value. 
Tell me more about how are you getting the value for $P{Id} ?
Is it in a dataset? Are u using it in a table? Or its just a parameter retrieved from an Input control?

Regards,
KKriplani

Link to comment
Share on other sites

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...