Two SQL query inside single JasperReport

AngelsandDemons picture AngelsandDemons · Jul 23, 2012 · Viewed 31.6k times · Source

We are generating reports based on iReports and JasperReports for web application.

Using iReports I found I am struck with big problem.

I want to use two SQL query to fill up my main report... In query designer I can only write one query..

For another query I cannot use sub-reports...

How do I write second query which will return different fields and include them in my report..

Please guide...

I cannot use sub-reports...

Answer

Gopinagh.R picture Gopinagh.R · Jul 23, 2012

Yes, adding a table to your report is as easy as adding a field. Just drag it from the palette and drop it in the report where you need to have it.

  1. Add a new Table data source. I assume this was done.
  2. Once the data source is configured, you could design your table UI using the wizard.
  3. just click on next or finish to close the wizard.

To add a parameter in data set (if needed), Navigate to your data set using the report inspector. Expand your data set. You would find the parameters menu. Right click to add the new parameter.

Now right click on your table and select edit table data source. Here you will find options to pass parameters to your table from the main report. Passing parameters to your table should be as simple as you do in sub reports. Select the parameter just created from the drop down list box and pass the required value. In the Data set run Dialog box that appears, please make sure of the data set and the report connection you are using. You are done configuring the table with this, next you will place the fields in the cells of table for displaying the data.

You are getting your document has no pages since the main report query does not return any rows i guess. For your table to be executed your main report must return at least a row

Hope this helps you.

Good Luck!!