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

Parameters as SQL list with iReport


schone

Recommended Posts

Hi all,

I just got started using JasperReports and I'm intially stuck on this parameter problem.

I have a report which is just a list of cities and the country they belong to.

I would like to create a list/dropdown parameter so that when the report is run a unique list of all countries available populate the list/dropdown and the user can select to filter the report on the selected country.

SELECT * FROM LOCATIONS WHERE COUNTRY_NAME = $P{COUNTRY_LIST}[/code]

I have set up a parameter called COUNTRY_LIST but when I run the report nothing appears in the drop down list, I also included this query in the default parameter value area:



SELECT DISTINCT(COUNTRY_NAME) FROM LOCATIONS[/code]
SELECT DISTINCT(COUNTRY_NAME) FROM LOCATIONS

And all I get is a incorrect token errror.



Can this be done in JasperReports?



Please help!



Thanks in advance!

Link to comment
Share on other sites

  • 2 months later...
  • Replies 9
  • Created
  • Last Reply

Top Posters In This Topic

It's not possible to define an input control with a list of countries in iReport or in JasperReports. It doesn't apply to these because JR is a report library and iReport is a report designer.

 

JasperServer can do exactly what you're describing. It has the concept of an "input control" the input control includes a query to get a list of values to be displayed to the user. Download that and take a look at the sample reports. Post to the JasperServer forum if you have questions implementing your input control.

Regards,
Matt
Jaspersoft

Link to comment
Share on other sites

  • 8 months later...
  • 2 weeks later...
  • 1 year later...

In iReport 3.0.0 I did SQL injection and it work.

I use zuckerReport, a php component that use a small Java class to pass the parameter from php to java and Jasper. So I guess you can do the same like that

 

My iReport where clause look like that

WHERE Q.contract_date BETWEEN $P{FROM} AND $P{TO} and

'' = $P{REP_LIST} = '' AND

Q.quote_stage = 'Confirmed' AND NOT Q.Deleted and p.quantity > 0

 

The parameter REP_LIST is use for the injection.

' AND Q.Assigned_user_id in ('','id1','id2','id3','id4') AND '

(iReport will circle the param with the other apostrophes)

So, at the end, we got something like that

WHERE Q.contract_date BETWEEN 'date1' AND 'date2' and

'' = '' AND Q.Assigned_user_id in ('','id1','id2','id3','id4') AND '" = '' AND

Q.quote_stage = 'Confirmed' AND NOT Q.Deleted and p.quantity > 0

 

Of course, you only can run it using some code, because the ireport GUI will parse an error on this param input.

 

Post Edited by aalexkun at 09/16/2010 17:00

Link to comment
Share on other sites

  • 1 year later...
  • 1 year later...

Hi aalexkun and bigteddo,

 

I have a similar problem, but when I try to apply that idea ireport displays an error warning.
>> first trial :  Error:org.postgresql.util.PSQLException: ERROR: invalid input syntax for type boolean: ''''
>> second trial : Error:org.postgresql.util.PSQLException: The column index is out of range: 18, number of columns: 17.
Here I am using iReport Designer version 5.1.0 and PostgreSQL 9.1.
I have tried to execute my query using pgAdmin III and produce the expected records. (but it is not successful in iReport)
anyone can help find the solution?
 
Thank you
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...