Using an Input Control in Report sql query


I am trying to use the value of an input control in my report sql statement and have a few questions. (For reference I have skimmed through the documentation once, and have searched through it many times trying to find answers - although I could have missed something.)

1. Can I create an input control in JasperReports Studio?

2. How do I put the result of the input control into the sql statement of the report? (I.e. what is its name to give to the query?)

3. I would also like to put the label of the selected value from the input query into the heading of the report. Is there any easy way of doing this.


My current sql statement is the most basic statement, for example:

SELECT * FROM dbo.cases

The table cases contains a column that is the result of the input control.



Jake Murphy

Far Edge Technology

jake_faredge's picture
Joined: Nov 6 2016 - 2:08pm
Last seen: 5 years 11 months ago

Ok, I just create an input control server side with the same name, simple.

I am wondering though, to run a report in Jaspersoft studio would I need to set the parameter to something special? (like something other than the "for prompt" option)

So in my situation the value of the input control is an id for a row of a table, easy enough to use in the report query. But how exactly would I be able to get other data from the same row? Like the name column and put it into the report, would this be where variables come into play?



Jake. (sorry if this is the wrong way of asking a clarifying my question)

jake_faredge - 6 years 4 months ago

1 Answer:


In JasperStudio you can create and use parameters in report query. You can create a parameter in parameter section of the report and then use it in the query like this:

select * from myTable where someValue = $P{myParameter}

If you mark parameter to be For prompt - True then you will be prompted to specify the value when compiling report.

The concept of input control exists only on JasperServer. You can create input controls for the parameters that exist in the report and add them to report unit resource on the server. The input control needs to have the same name as the parameter you want to wire it to.

Take a look at this sample for more information about using parameters in query:

Chapter 8 of the JasperSoft Studio User Guide also provides details about parameters and parameter usage in the query.

Chapter 5.3 and specifically 5.3.2 of the JasperReports Server User Guide provides information about input controls on the server side.

Friendly User's picture
Joined: Oct 8 2009 - 5:59am
Last seen: 1 week 3 days ago