Jump to content
Changes to the Jaspersoft community edition download ×

Using an Input Control in Report sql query


jake_faredge

Recommended Posts

Hello,

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.

 

Thanks,

Jake Murphy

Far Edge Technology

Link to comment
Share on other sites

  • Replies 2
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

Hello,

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:

http://jasperreports.sourceforge.net/sample.reference/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.

Link to comment
Share on other sites

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?

 

Thanks, 

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

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