6

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

AngelsandDemons
  • 2,823
  • 13
  • 47
  • 70
  • 1
    possible duplicate of [Multiple queries in a single jasper document](http://stackoverflow.com/questions/7482412/multiple-queries-in-a-single-jasper-document) & http://stackoverflow.com/questions/11604391/having-many-seperate-unrleated-datasets-in-ireport – Alex K Jul 23 '12 at 11:21

2 Answers2

6

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

Gopinagh.R
  • 4,826
  • 4
  • 44
  • 60
  • Great explanation...The issue was that I was not passing a report connection to the table...Once I did that it started working perfectly..Thanks for the help..Table dataset really serves my purpose upto great extent... – AngelsandDemons Jul 24 '12 at 05:43
  • Hello...Thanks..But including multiple table datasets in landscape type report is causing a problem..Please refer this link..http://stackoverflow.com/questions/11646062/multiple-blank-pages-appearing-before-summary-section-in-jasperreports – AngelsandDemons Jul 25 '12 at 10:19
  • I just had a glance at the problem you have been facing. I feel posting your jrxml would aid in suggesting an solution to the problem. – Gopinagh.R Jul 27 '12 at 04:24
2

As far as Ireports are concerned, the main report can comprise only one query. And if you wanna use multiple queries in your report, it is possible in the following ways.

  • Sub Report
  • Table Dataset.
  • sub Dataset.

since you don wish to use a sub report, you can go for a Table Dataset. Anything you would do with a sub report is possible with table dataset too(Except for returning variables). You can use sub datasets with charts and graphs. Table set will be of use to you i hope.

Gopinagh.R
  • 4,826
  • 4
  • 44
  • 60
  • I know about subDatasets..But as you mentioned it can only be used in charts and graphs... For Table Dataset I assume I need to drag a table from palette and configure its properties to use a new database query...I am doing the same thing....However eveyrtime I get "The document contains no pages"....Do I need to do anything else with regard to the tabledataset....Also it's not present in the iReport document..Can you please help... – AngelsandDemons Jul 23 '12 at 08:33