Need to pass a list as parameter to report ? The answer is this can't be done with current BIRT 4.5.0 implementation , but we have alternatives :
Why it can't be done ?
When creating a "New Parameter" , there is no such "Data Type" as "List"
What is the use case ?
oid | username |
1 | Jeff |
2 | Tom |
3 | William |
Suppose we have a "String" type parameter : paramoid , and JDBC datasource with below query :
select oid as "ID" , username as "NAME"
from table_user
where oid in (?)
When we pass in "2,3" from application to report as paramoid , the report engine would get data with below SQL query which is obviously wrong :
select oid as "ID" , username as "NAME"
from table_user
where oid in ('2,3')
Solution : use data set pre open
Rewrite SQL to below :
select oid as "ID" , username as "NAME"
from table_user
where ##oid_condition##
Click on the dataset that being used and put below code to "Before open" :
var oidSelected=reportContext.getParameterValue("paramoid");
this.queryText = this.queryText.replace("##oid_condition##" , " oid in ("+ oidSelected +")");
In the end , at runtime the SQL become :
select oid as "ID" , username as "NAME"
from table_user
where oid in (2,3)
No comments:
Post a Comment