pass dataset from main report to subreport without using java code

0

I have a main report and three subreport which use the same sql, that sql is quite time consuming, so for the same sql it runs total four times ( one main + 3 subreport), I want to speed up the processing time by passing the main report dataset result to these three subreport, without using any java code. As I see some post mention to pass the dataset from java to main report parameter, then to subreport parameter, but this is not a option for me, my application is .net based.

tong123123's picture
Joined: May 4 2010 - 4:19am
Last seen: 1 week 3 hours ago

3 Answers:

1

Are you passing any custom dataSource to the main report from outside or is the SQL-query just placed within the main-report and takes so long at filling level?

What should happen if you pass the whole main-dataset to the first subreport and this subreport iterates further through the records? If the subreport is finish the internal cursor in your main-dataset is moved forwards and the main-report is actually at the end?!?! So the main and also the next SubReport(s) won't render anything because the first SubReport consumed all records!?!

So you would need a kind of a "copy" of your DataSet. I know that the JRBeanCollectionDataSource does have a cloneDataSource-Method - so I used it within the last years intensive, but not sure, whether you could "copy" or "rewind" a "normal JRDataSource" also. 

Why do you actually use SubReports for the same datasource? What is your intention behind? Do you just want to display some rows from the main-dataset in different ways and filter them out within the SubReport itself?!?

regards 

C-Box

C-Box's picture
1327
Joined: Jul 19 2006 - 5:58pm
Last seen: 5 hours 54 min ago
0

Hi C-Box

The sql is placed in main report <queryString>, and the three subreport is placed in main report  three different group header, each with expression 

$P{REPORT_CONTEXT}

In fact the report is not written by me but I need to maintain this report,

what is group header with expression  $P{REPORT_CONTEXT} means? Mostly I see group heder expression is a field like $F{FIELD_A}, this means the group header will reprint when value of $F{FIELD_A} change. But what happen when group header expression is $P{REPORT_CONTEXT}? it means that group header will just run once for the whole report?

2) Why do you actually use SubReports for the same datasource?

Yes, in fact I think can just copy the content of subreport to the main report corresponding subreport component group header, just set the group header to the size of subreport, right?

tong123123's picture
Joined: May 4 2010 - 4:19am
Last seen: 1 week 3 hours ago
1

Well, I've never used the REPORT_CONTEXT ... so I guess this is more a workaround in your JRXML to have any expression for your group(s). For let's call "Dummy Groups" you also could leave the groupexpression emtpy or set it to null ... so as the REPORT_CONTEXT probably won't change it's value your groups will be something like "dummy groups" just to have different group header/footer to call different SubReports - so this is my guess.

So as you just have the SQL query inside the main report - there are two ways:

1.) Run this query outside and "wrap" the ResultSet into a DataSource that is cloneable (like JRBeanCollectionDataSource). So you can "reuse" this datasource with the clone() Method in DataSourceExpression  for your SubReport. ... But of course this would need some work in Java, what your initial subject doesn't wanted.

2.) Redesign your main-report to present the records directly within the MainReport and delete your SubReport(s) - if this is feasible. (be aware, if the SubReports itself doesn't have a filter-expression or something like this)

or even 3.) optimize your query.... perhaps there is just an index missing!?!? :-)

 

hth + regards from sunny Dresden/Germany

C-Box

C-Box's picture
1327
Joined: Jul 19 2006 - 5:58pm
Last seen: 5 hours 54 min ago
Feedback