Jump to: navigation, search

Difference between revisions of "Null Report Parameter Passed to Data Set (BIRT)"

(New page: {{Backlink|Report Developer Examples (BIRT)}} This example is [https://bugs.eclipse.org/bugs/show_bug.cgi?id=182197 Bugzilla ID 182197]. If you would like to contribute an example see the...)
 
(Comments)
 
Line 27: Line 27:
 
If the report parameter is null this code will not be executed.  If the parameter is not null the query is altered to append the parameter to the where clause.
 
If the report parameter is null this code will not be executed.  If the parameter is not null the query is altered to append the parameter to the where clause.
  
== Comments ==
+
for more complex query it's not a good solution
Please enter comments below by selecting the edit icon to the right.
+
You will need a Bugzilla account to add comments.
+
----
+
[[Category:BIRT]]
+
[[Category:BIRT Example]]
+
[[Category:BIRT Example Report]]
+

Latest revision as of 17:46, 22 August 2010

< To: Report Developer Examples (BIRT)
This example is Bugzilla ID 182197. If you would like to contribute an example see the example contribution guidelines.

Introduction

This example illustrates handling a null report parameter before using it in a data set parameter.

BIRT Version Compatibility

This example was built and tested with BIRT 2.1.2.

Example Files

Example Report Zipped

Description

BIRT Supports Report Parameters and Dataset Parameters. A Report parameter can be setup to accept null values. JDBC Dataset parameters are created when using the ? within the SQL Editor. The dataset parameter is then linked to a report parameter in the dataset editor (Parameters entry). This works fine unless the parameter is null. To deal with this problem you can tie your report parameter to the dataset in the beforeOpen event handler for the dataset. In the attached example the query that is used is as follows:

select *
from orderdetails
where CLASSICMODELS.ORDERDETAILS.ORDERNUMBER is NULL 

So the default query is looking for null order numbers. The report also has a parameter that has the allow null check box checked. In the beforeOpen script for the dataset the following is entered.

if (params["NewParameter"].value){
           this.queryText = "select * from orderdetails where CLASSICMODELS.ORDERDETAILS.ORDERNUMBER =" + params["NewParameter"];
}

If the report parameter is null this code will not be executed. If the parameter is not null the query is altered to append the parameter to the where clause.

for more complex query it's not a good solution