Jump to content

Single JRXML, multiple SQL Queries???


sukirtha

Recommended Posts

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

  • Replies 6
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

  • 5 years later...

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 condition
and returns the query. 
I hope this helps.

 

 

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