Two SQL queries inside one JasperReport

We create reports based on iReports and JasperReports for web applications.

Using iReports, I found that I have a big problem.

I want to use two SQL queries to populate my main report ... In the query designer, I can write only one query.

For another request, I cannot use subheadings ...

How to write a second query that will return different fields and include them in my report ..

Please guide ...

I can not use subtitles ...

+6
source share
2 answers

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

  • Add a new table data source. I guess that was done.
  • After setting up the data source, you can create your table user interface using the wizard.
  • just click on or complete to close the wizard.

To add a parameter to the data set (if necessary), go to your data set using the report inspector. Expand your dataset. You will find the options menu. Right-click to add a new parameter.

Now right-click on your table and select edit table data source. Here you will find parameters for passing parameters to the table from the main report. Passing parameters to a table should be as simple as in sub-reports. Select the option you just created in the drop-down list and pass in the desired value. In the Define Dataset dialog box that appears, make sure that you are using the dataset and connection to the reports. You have finished setting up the table with this, then you put the fields in the cells of the table to display the data.

You get your document without pages, since the main report request does not return any rows that I assume. For your table to be executed, your main report must return at least a row

Hope this helps you.

Good luck !!

+6
source

For Ireports, the main report can only contain one request. And if you want to use several queries in your report, this is possible in the following ways.

  • Subsection
  • Dataset table.
  • sub dataset.

since you do not want to use an additional report, you can go to the tabular dataset. Everything that you do with an additional report is also possible with a tabular data set (except for the returned variables). You can use auxiliary databases with charts and graphs. A desktop set will be useful to you.

+1
source

Source: https://habr.com/ru/post/921101/


All Articles