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

Operations with parameters before query


GonzaLinares
Go to solution Solved by riodavid,

Recommended Posts

I´m using Jaspersoft Studio 6.5

In a new report, i want to do some operations with parameters before the query is executed and brings report data
For example, as a parameter i ask user to insert a date.
I want to calculate days passed from that date. Then pass those days to seconds and use those seconds in the query.

Is there anyway to do this?

A workaround i thought that may work was to create a new parameter, and do not promp it.
In it expression, do the operations and then use that parameter in the query. By doing this,  i use this 2nd parameter as a "function" that operates with the parameter

1st Parameter:
Name: dateParam
Type: java.util.Date
Default Expression: -
Is For Prompting: Checked

2nd Parameter:
Name: secondsParam
Type: java.lang.Long
Default Expression:     new org.joda.time.DateTime($P{dateParam}).getMillis()/1000
Is For Prompting: Not checked

Both of them have Early evaluation time.
Then in the query i use 2nd parameter. i.e    ... WHERE P${secondsParam} > ticketTable.openDateSeconds 

After doing this, it actually work in Jaspersoft Studio. But when trying to execute it on JaspersoftReports Server, 2nd parameter don´t take 1st parameter value.


 

Link to comment
Share on other sites

  • Replies 4
  • Created
  • Last Reply

Top Posters In This Topic

Finally find a solution.Did something similar to what you said.
Created a input control asking for the date. Then used 2nd parameter to convert value in the input control.

I guess all parameters have same evaluation time, but input controls have an earlier evaluation time.Hence, 2nd parameter does take value from 1st parameter
(At least at Jaspersoft Server, since it worked with 2 parameters in Jaspersoft Studio)

 

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