Operations with parameters before query

0

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.


 

GonzaLinares's picture
Joined: Apr 17 2018 - 10:50am
Last seen: 8 months 2 days ago

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)

 

GonzaLinares - 1 year 3 months ago

Good to know you did it!

riodavid - 1 year 3 months ago

2 Answers:

1

I think you can re-write the logic of the 2nd parameter to SQL, and implement it in Input Control. That's how cascading input control works.

riodavid's picture
502
Joined: Oct 27 2016 - 1:57am
Last seen: 9 months 2 weeks ago
0
hozawa's picture
46867
Joined: Apr 24 2010 - 4:31pm
Last seen: 2 months 1 week ago
Feedback