sukirtha Posted July 11, 2008 Share Posted July 11, 2008 Can a single JRXML contain two queries? I have a main report. In the main report I need to populate data using two different queries. I know we can do this using subreports as subreports may increase the processing time. Is there any other way to populate from two different datasources in a single jrxml. FYI,The bands that need to be populated are ColumnHeader band and Detail Band. Thanks. Link to comment Share on other sites More sharing options...
rbojja Posted July 11, 2008 Share Posted July 11, 2008 can you send me the code for executing subreports in java Link to comment Share on other sites More sharing options...
dnvsrikanth Posted July 11, 2008 Share Posted July 11, 2008 Hi sukirtha, If I am not wrong, a single JRXML doesn't contain two queries as JR can process only one ResultSet at a time. DNV Srikanth Link to comment Share on other sites More sharing options...
dnvsrikanth Posted July 11, 2008 Share Posted July 11, 2008 hi rbojja There is a good sample given by JasperReport guys. Check out the subreport folder under demo/samples folder. DNV Srikanth Link to comment Share on other sites More sharing options...
sukirtha Posted July 11, 2008 Author Share Posted July 11, 2008 Does that mean I will have to use subreports only :( that will impact my performance.... Link to comment Share on other sites More sharing options...
pramod3181990 Posted October 24, 2013 Share Posted October 24, 2013 Yes, you can have more than one query in jrxml although you can run only one query. You can have a condition based on which you want you want to fire the query during run time and I think this is what you want.Take a look at the follwing:<parameter name="param" class="java.lang.String"> <defaultValueExpression><![CDATA[]]></defaultValueExpression></parameter><parameter name="query" class="java.lang.String" isForPrompting="false"> <defaultValueExpression><![CDATA[(new String("postgres").equals($P{param}) ? "select * from employee limit 5" : "select * from employee where ROWNUM>=1")]]></defaultValueExpression></parameter><queryString> <![CDATA[$P!{dbType}]]></queryString>Here's the explanation:Use the first parameter(param) for entering the value based on which you want your query to be picked during run time. Based on this value the query is picked and gets set in the second parameter(query). You can see the conditional operator being used in the second parameter. This checks the conditionand returns the query. I hope this helps. Link to comment Share on other sites More sharing options...
pramod3181990 Posted October 24, 2013 Share Posted October 24, 2013 http://www.coderanch.com/t/435096/open-source/RESOLVED-jasper-iReport-multi-reports 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