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

Dynamic parameters being ignored


matt_23

Recommended Posts

'm finding that using the preview tool is ignoring the parameters that I'm passing. This is for old reports that I built months ago and have always worked perfectly. I'm entering the values in the preview window, but according to the SQL it's seen as null values when they aren't!


I recently upgraded , only from 6.0.1 to 6.1.1 I think.


The way I deal with parameters is I have a user-editable one, e.g.


<parameter name="MerchantID" class="java.lang.Integer"/>[/code]

And then a hidden parameter that generates the SQL for the where clause:


<parameter name="MerchantID_Query" class="java.lang.String" isForPrompting="false">  <defaultValueExpression><![CDATA[$P{MerchantID} == null ? "" : " AND gr.MERCHANT_ID = " + $P{MerchantID} + ""]]></defaultValueExpression> </parameter>[/code]

But all that gets passed is null, so the parameters have no effect. I've tried various options and have been deliberately breaking the code so that I can see the full generated SQL in the error pop-up. But it keeps passing null despite that being a value - I just don't get it!


Any ideas?


 


Link to comment
Share on other sites

  • Replies 2
  • Created
  • Last Reply

Top Posters In This Topic

That way of passing parameters has given me some trouble in the past, what I started doing instead is the following:

       In the SQL query, write something like this:

           SELECT * FROM table WHERE (gr.MERCHANT_ID = $P{MerchantID} or $P{MerchantID} is null);

What this does is, if the Parameter has a value it compares it against the field you specify, otherwise it defaults as true.

Sorry if this doesn't repond your question, its what I understood of it.

Link to comment
Share on other sites

Hi Javier

I did try that method as well and got the same results as my normal methods, the parameters were getting ignored. 

In the end, I managed to fix the issue. Although the 'check for update' tool was saying I had the most up to date version, I checked the Jasper website and discovered I didn't (was on 6.0.1 not 6.2.x). A full reinstall later and it started working as expected again.

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