fender989100 Posted August 2, 2016 Share Posted August 2, 2016 HiI have input id param in my report.If id == null then I need to use a query like this:SELECT id, nameFROM company But if id == 1 (or another number)I need to use that query:SELECT id, nameFROM company WHERE id = 1I'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 More sharing options...
kkriplani Posted August 2, 2016 Share Posted August 2, 2016 Yes, it is very much possible to do so using conditional parameters (see the last answer in this link ) represented as $!P{}Try approaching like this;$P{Id} == null ? "where 0=0" : "where id=" +$P{Id};Regards,KKriplani Link to comment Share on other sites More sharing options...
fender989100 Posted August 2, 2016 Author Share Posted August 2, 2016 ThanksI know about that technic, but It's not working.$P{Id} == null ? "where 0=0" : "where id=" +$P{Id};$P{Id} always will be null in current expresion, no matter param was fiels or not Link to comment Share on other sites More sharing options...
kkriplani Posted August 3, 2016 Share Posted August 3, 2016 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 More sharing options...
fender989100 Posted August 3, 2016 Author Share Posted August 3, 2016 Thank you KKriplani It works Jasper Soft Studio has some troubles with Preview mode When I've uploaded report to the Server everythings start to work Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now