Jump to content
We've recently updated our Privacy Statement, available here ×

chelorossel

Recommended Posts

  • Replies 3
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

I just used a List for the first time last week.  Here were some notes I typed for myself.  The main example I use is that I have several reports where I want a variable called ENV.POSTING_DATE (ENV is a table that only has a single row) to appear in the Title of reports, but it's not needed in the main report, so including a JOIN in the main SQL query is overkill, as is a subreport:

If you need to include data from a separate query (dataset), but don’t want to create a whole separate report, you can often use a List component to solve the problem.  For example, you may want to include the ENV.POSTING_DATE at the top of the report.  Here are the steps for creating and using a List:

·         With the report open in the Design View in iReport, drag a List component from the Element Palette to the appropriate band of the report.  This creates a new subdataset that you can see in the Report Inspector.  Initially it is called dataset1, but you can rename it to “DatasetPostingDate”, for example.

·         Set the query of the subdataset by right clicking the subdataset node in the Report Inspector pane and selecting the menu item “Edit Query”.  Use the same query that you might use in a subreport.  In this case, perhaps:

SELECT ENV.POSTING_DATE AS PostingDate FROM CORE.ENV AS ENV

·         If the subdataset query requires any parameters, you can create those as you would for the main report, but underneath the subdataset in the Report Inspector.  This is where you will see parameters, fields, variables, and groups that are specific to the subdataset.

·         Configure the dataset run: right click the List element and select “Edit List Datasource”.  A “Dataset run” dialog box comes up.  In the Sub dataset dropdown, select the name of the subdataset.  In the Connection/Datasource exp pane, choose “Use connection expression” in the dropdown.  You should already see $P{REPORT_CONNECTION} in the main pane, which is correct if you want your subdataset to use the same report connection that the main report uses.  If you have any parameters that are used as input for the subdataset query, select the “Parameters” pane and “Add” a parameter.  For example, maybe add a parameter called “EndDate” and make the expression be $P{EndDate}, which would feed the parameter from the main report to the subdataset query.  Or you could feed it a field from the detail of the main query, etc.

·         Design the content of the List:  drag static text from the palette, drag subdataset fields from the subdataset, etc.  Resize the List if necessary.

·         Save and test.  If it works, you now have essentially the benefit of a subreport, but without using an additional resource.  List is also rumored to be faster than a subreport, I’m guessing because a subreport probably gets recompiled at runtime, while a List is part of the original compilation of a main report.

 

Hope that helps!

Carl

Link to comment
Share on other sites

  • 2 years later...

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