This example uses two parameters to modify the source for a query used to build a table on a report. The parameters are added to the query text dynamically from the
beforeOpen scripting event on the Data set. In that event the query text is modified by over-writing the
this.queryText variable. A customer name and product line are added to filter the query down to 13 rows. Remove the filters and the query wiull retrun a far greater row count (greater than 500). Doing the parameter substitution in the scripting layer makes it possible to use a different set of parametersa at run-time. Formally binding parameters to a data set will force the count of parameters used in the query to always match. Not as flexible.<br />
The attached sample features a data set built without any dynamic filters at all. The report also features three parameters:
<br />
- pCustomer: Choose a customer to filter on<br />
- pProdLine: Choose a product line to filter on<br />
- pModQuery: A Boolean value to control the modification of the query (so you can see the difference with modification on and off).<br />
<br />
This sample will add both parameters into the query if
pModQuery is set to TRUE. You could add additional logic using if/else blocks to control what parameters are added. You can get as creative as your needs dictate in how you build out this query.<br />
Built on BIRT 2.3 using Classic Models data. Nothing else needed if you want to load in into BIRT and have a look.<br />
Good Luck!