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

Using One Datasource for Multiple Sub-reports


dan_thorman

Recommended Posts

I have one main report with 2 subreports. The 2 subreports are in the details section of the main report. I want to pass to each the same parameter, and for each to evaluate for the same parameter, so that i get a table that looks something like this:

 

 

brand name 1: condition1count condition1sum condition2count condition2sum

brand name 2: condition1count condition1sum condition2count condition2sum

brand name 3: condition1count condition1sum condition2count condition2sum

 

etc. where condition1count and condition1sum are the results of 1 of the sub-reports and condition2count and condition2sum are the results of the other sub-report.

 

in the main report, i am using a jdbc connection to an oracle database to pull distinct brand names and their unique id's, and i want to pass the unique id to the sub-queries as it is a condition in the query they run.

 

The problem i have is that sub-report 1 is evaluating correctly, but sub-report 2 is returning all null data.

 

What did i do wrong?

Link to comment
Share on other sites

  • Replies 4
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

Possibilities include:

 

 

* You've inadvertently forgotten to pass the paremeter to the second subreport. Check your sub-report's properties and make sure the parameter(s) are correctly defined.

 

* The parameter has been omitted from the query for some reason. Check you sub-report's SQL query and make sure it makes use of the parameter.

 

* The parameter value used results in an empty record set. Run the query in the database environment (rather than through iReports) to make sure it works. Substitute a static value for the $P{yourParametersName} in the query.

 

* The SQL always returns an empty recordset. Make sure your query returns some values even when you remove the clause that includes the parameter.

 

* This might sound silly, but misteaks do happen: check the data source for your textfields is set properly. When you're busily copying and pasting it's easy enough to forget to set the Text Field Expression.

Link to comment
Share on other sites

I think the data source is emptied when it's used that's why it works for first subreport but not the following.. I had a similiar problem and I didn't find a solution for it. I'm working my problem around another way but if you find out a solution (how to refill result set), please say how you did it :)

 

Pedro.

Link to comment
Share on other sites

One other thing to remember when working with sub-reports is that you have to recompile any sub-report when you change the source xml. This is because the jasper engine will be looking for a precompiled .jasper file, not the source xml/jrxml file.

 

 

I have attached a sample report with two subreports and sample output. Both subreports display exactly what they are supposed to display. I hope you can find something in the sample to help you with your problem.

 

 

The zip file contains 3 x jrxml and one pdf that will extract to C:ReportsDigiTollPROXY

 

[file name=Protocol.zip size=5675]http://www.jasperforge.org/components/com_joomlaboard/uploaded/files/Protocol.zip[/file]

Link to comment
Share on other sites

First, sorry for the multiple postings... my web browser messed up and i didn't realize it ended up posting twice until it was too late.

 

Secondly, thank you all for your help. There was some great advice there, and I tried it all. However, none of it seemed to work. Here is what did:

 

For the life of me, I simply could not figure out what I did wrong. So, I deleted the sub-report section on the main report that was supposed to link to that second sub-report. I copy/pasted the sub-report section that linked to the first report, and simply changed the name of the file that it was pointing to. That worked.

 

I'm running into a few issues with certain static text printing, and certain static text not printing, but i'm sure that i'll be able work my way around that somehow.

 

Again, thanks for all of your help!

Link to comment
Share on other sites

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