Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
Only execute dataset query if parameter is filled
AnnaB
Hi!
My reports contain an optional parameter P. If P is filled, I need to run a query Q. If not, Q doesn't need to run, because it would not contain relevant information.
Running Q takes a long time so I don't want it to if P is not filled. I'm sure there's a simple method to do this, but I can't find it! Can anyone help?
I'm running BIRT v.4.2.0 in Eclipse Juno.
Find more posts tagged with
Comments
kclark
You could drop the table/grid based on the parameter like <a class='bbc_url' href='
http://www.birt-exchange.org/org/devshare/designing-birt-reports/1027-drop-a-table-based-on-a-report-parameter/'>this
devshare</a> You would use this in the beforeFactory()<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
CustomerTable = reportContext.getReportRunnable().designHandle.getDesignHandle().findElement("Customer");
EmployeeTable = reportContext.getReportRunnable().designHandle.getDesignHandle().findElement("Employee");
if (params["Table"].value == "Customer Table"){
EmployeeTable.drop();
}
else{
CustomerTable.drop();
}</pre>
<br />
Or if you wanted to change the query itself you could do something like<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
if (params["someParam"] == "some value") {
this.queryText = this.queryText.replace("SQL STMT");
}else{
// some other logic?
}
</pre>
AnnaB
Thanks! I was looking for the second option.<br />
<br />
Only if I try to do that in the beforeOpen, I get an error: <br />
<pre class='_prettyXprint _lang-auto _linenums:0'>Script engine error: Can't find method java.lang.String.replace(string).</pre>
<br />
Any thoughts as to what that could be?