2004 IR Help Posted September 2, 2006 Share Posted September 2, 2006 By: laj lal - lajslal Multiple queries in one Report 2004-07-26 23:28 Is it possible to create a single report with multiple queries? For example, display a table which is the result of Query1 on Table1 in the database, followed by another table which is the result of Query2 on Table2. I am new to iReport, and therefore the concept of bands and groups is slightly confusing and is leading me to believe that the above scenario is not possible with iReport. Am I wrong? Could you use subreports to do it? If so, how? Any help would be greatly appreciated. By: olivier849 - olivier849 RE: Multiple queries in one Report 2004-07-27 00:35 yes it's possible using subreports, you just pass the connection to the subreport wich have it's own query to run. I hope that helps... By: laj lal - lajslal RE: Multiple queries in one Report 2004-07-27 01:01 What if there IS no connection? Basically, two completely unrelated tables generated from two separate queries. Suppose I have two reports, named Report1 and Report2. Report1 generates a tabular report, and for argument's sake let's say the query is "select * from table1". And Report2 does a similar thing, with "select * from table2". Now suppose I create a master report, named ReportMaster. I want ReportMaster to contain the tables generated in Report1 and Report2, one after the other. But I don't see that possible with the Band system that JasperReports seems to use, since both Report1 and Report2 use the ColumnHeader band and Detail band, and therefore I don't know how to use subreports in such a way that I can show them both in this one report. I hope that makes my situation clearer. Any ideas? Thanks again for any help. By: Mark Rhodes - mrhodes2 RE: Multiple queries in one Report 2004-07-27 09:52 A connection doesn't matter. Create as many groups as you want subreports. Create headers for each group and place the subreport in the header. You'll have to play around w/ line heights and page breaks. I do this. I have a master report that calls 7 subreports. Subreports and student information, labor info and inventory information by location. Nothing about data is related. By: laj lal - lajslal RE: Multiple queries in one Report 2004-07-27 19:53 Thanks Marc, for the instructions. I'm trying out what you told me, testing it now with just one subreport, but am getting errors during compilation: The master report is called test_master, and the subreport is called test_detail. The subreport runs fine on its own. But when I run the master report, which calls test_detail.jasper as a subreport, I get the following compilation error: java.io.FileNotFoundException:?C:Documents?and?SettingsLajデスクトップiReport?tempiReport-0.3.2test_master.class?(指定されたファイルが見つかりません。) (my apologies for the non-English font, am using a Japanese version of Windows - the thing in brackets at the end basically says the file could not be found) Any ideas why it's looking for a test_master.class? In the directory which it's looking in, I can see a test_master.jrxml, a test_master.jrxml.bak, and a test_master.jasper . . . no test_master.class, which I don't know why it's looking for. What am I doing wrong? Thanks again in advance. By: laj lal - lajslal RE: Multiple queries in one Report 2004-07-27 22:42 Never mind, I got it working. Just had to replace backslashes with double backslashes to get the subreport expression string to recognize the escape characters. But I still have problems! It compiles fine now, but at runtime I get an error that says "the document has no pages" . . . I think this has something to do with what Marc said in a previous response: "You'll have to play around w/ line heights and page breaks." Am I right, Mark? Or is this issue completely unrelated? Thank you. By: bcinteractive - bcinteractive RE: Multiple queries in one Report 2004-07-28 05:52 Try adding a query in your master report. like SELECT "smile" AS programmer This way the report has something to work on. By: laj lal - lajslal RE: Multiple queries in one Report 2004-07-28 19:58 Thanks! That worked miracles. Added an arbitrary query to the master report, and now it compiles and runs. But the page is still blank. I don't see the detail report, just a blank white page. I tried adding an arbitrary title to the page, but that displays fine. I went back to the detail report, but running that on its own displays the report correctly. Somehow the master report is not tying the two files together . . . Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now