Richie
Richie

Reputation: 5199

BIRT reports stop hidden queries from being executed

I have a BIRT report which has a number of tables which get set to not visible based on the parameters that are passed into the report.

I read on the internet that the queries bound to those tables will still get executed unless I drop the tables in the beforeFactory script. In addition to dropping the tables do I also need to drop the queries as well? Or is dropping the tables where the queries are bound to enough for the queries not to be executed?

Is there anyway I can tell if those hidden queries have been executed?

Here is my beforeFactory script which shows how I am dropping the tables....

var tblPriceOverrideDetailDesc = reportContext.getReportRunnable().designHandle.getDesignHandle().findElement("tblPriceOverrideDetailDesc");
var tblPriceOverrideDetailAsc = reportContext.getReportRunnable().designHandle.getDesignHandle().findElement("tblPriceOverrideDetailAsc");
var tblPriceOverrideDetailExclConcessionDesc = reportContext.getReportRunnable().designHandle.getDesignHandle().findElement("tblPriceOverrideDetailExclConcessionDesc");
var tblPriceOverrideDetailExclConcessionAsc = reportContext.getReportRunnable().designHandle.getDesignHandle().findElement("tblPriceOverrideDetailExclConcessionAsc");

if ( ((params["bp_sortType"].value).equals("DESC") && params["bp_excludeConcessionInd"].value != null)
    || (params["bp_sortType"].value).equals("ASC") ){
    tblPriceOverrideDetailDesc.drop();

} else if( ((params["bp_sortType"].value).equals("ASC") && params["bp_excludeConcessionInd"].value != null)
            || (params["bp_sortType"].value).equals("DESC") ){
    tblPriceOverrideDetailAsc.drop();

} else if( ((params["bp_sortType"].value).equals("DESC") && params["bp_excludeConcessionInd"].value == null)
            || (params["bp_sortType"].value).equals("ASC") ){
    tblPriceOverrideDetailExclConcessionDesc.drop();

}else if( ((params["bp_sortType"].value).equals("ASC") && params["bp_excludeConcessionInd"].value == null)
          || (params["bp_sortType"].value).equals("DESC") ){
    tblPriceOverrideDetailExclConcessionAsc.drop();

}

Upvotes: 2

Views: 853

Answers (1)

Simulant
Simulant

Reputation: 20140

What you read is correct. The Data-Select for a hidden Table will still be executed, because of the execution pipline. First the data gets fetched and afterwards the table gets rendered (where it gets hidden, but there is no check for visibility before fetching). If the table is deleted the query will not be executed because data is only fetched right before it is used.

To check if a Select is executed you could add the following for debugging into your Report (and remove it for product use).

Select your Data Set in the Data Explorer -> click on Script -> select the onFetch script -> add the follwoing line into the scrip area:

reportContext.setPersistentGlobalVariable("tag", "executed");

add a Dynamic Text-Field to your Report as the last element with the content:

reportContext.getPersistentGlobalVariable("tag")

if the Query is executed the text-field says "executed". If it is not executed is says "null" or it is simply blank.

Upvotes: 4

Related Questions