Search code examples
jasper-reports

Match table-record to main-report dataset in Jaspersoft Studio


I have a question about reports with Jaspersoft (Jaspersoft Studio v. 6.5.1). I have two tables (they are actually views, but that should not matter?!) from a Postgresql database. From "customers" I have created a report, each record has its own page (works fine). Now I want a output of the corresponding record from "Orders" as a table to the corresponding page. Unfortunately, I always get all the table recods on every page. Does anyone have an indication how I can solve this?

Customers:

Cust_ID Attribute_1 Attribut_2
1       xy          xy
2       xy          xy
.       ..          ..

Orders:

Ord_ID Cust_ID Article
1      1       xy      
2      1       xyz     
3      2       xz      
.      .       ..

Solution

  • @Alex K Of course you use tables or subreports for that, but unfortunately that is only half the solution.

    That helped further: https://community.jaspersoft.com/wiki/subreports

    The solution is to use a parameter at the database query of the subreport / table. This can then be used to refer to the id of the main report.

    With the given sample tables above:

    SELECT * FROM Orders WHERE Cust_ID = $P{ID_Customer}