jadey Posted July 15, 2010 Share Posted July 15, 2010 Hello people;I have reports where requests ("where") must be dynamic.I would write something like:select t.champfrom table twhere t.TRADEDATE <= case when $P{datedeb} is null then a.TRADEDATE else $P{datedeb} endbut it doesn't work whileselect t.champfrom table twhere t.TRADEDATE <= case when $P{datedeb} ='01/01/3000' then a.TRADEDATE else $P{datedeb} endworks fine.In short, if a parameter is the an empty string or null then not integrate them as conditions on the "where"I saw that it is permitted to use an object of type "JRDesignQuery" to build the request in java. Two pitfalls for this method:1 - Forced to recompile each time the report (I've been using the compiled .jasper reports)2 - The real pitfalls: I have a lot of reports and the requests are enormous. It would quickly become unmanageable if report request are in java side.There's also another possibility to pass the request as a parameter to the report. This solution has the same constraints, and is similar in all points to the first.If someone has a solution to propose to me I shall be grateful to him.Thank you for all your contributions. Link to comment Share on other sites More sharing options...
lucianc Posted July 29, 2010 Share Posted July 29, 2010 You can use $P!{..} and a derived parameter for that. See below.HTH,Lucian Code:<parameter name="QueryFilter" isForPrompting="false"> <defaultValueExpression>$P{datedeb} == null || $P{datedeb}.equals("") ? "" : "when $$P{datedeb} ..."</defaultValueExpression></parameter><queryString>select ... where P$!{QueryFilter}</queryString> 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