【发布时间】:2014-09-09 13:19:29
【问题描述】:
当我尝试从报告参数传递多个值时,我遇到了 BIRT 问题。
我正在使用 BIRT 2.6.2 和 eclipse。
我正在尝试从级联参数组的最后一个参数“JDSuser”中放入多个值。参数允许有多个值,我使用的是列表框。
为了能够做到这一点,我正在使用 where-in 语句编写我的 sql 查询,其中我用 javascript 替换文本。否则 BIRT sql 无法从报告参数中获取多个值。
我的sql查询是
select jamacomment.createdDate, jamacomment.scopeId,
jamacomment.commentText, jamacomment.documentId,
jamacomment.highlightQuote, jamacomment.organizationId,
jamacomment.userId,
organization.id, organization.name,
userbase.id, userbase.firstName, userbase.lastName,
userbase.organization, userbase.userName,
document.id, document.name, document.description,
user_role.userId, user_role.roleId,
role.id, role.name
from jamacomment jamacomment left join
userbase on userbase.id=jamacomment.userId
left join organization on
organization.id=jamacomment.organizationId
left join document on
document.id=jamacomment.documentId
left join user_role on
user_role.userId=userbase.id
right join role on
role.id=user_role.roleId
where jamacomment.scopeId=11
and role.name in ( 'sample grupa' )
and userbase.userName in ( 'sample' )
我在 beforeOpen 状态下的那个数据集的 javascript 代码是:
if( params["JDSuser"].value[0] != "(All Users)" ){
this.queryText=this.queryText.replaceAll('sample grupa', params["JDSgroup"]);
var users = params["JDSuser"];
//var userquery = "'";
var userquery = userquery + users.join("', '");
//userquery = userquery + "'";
this.queryText=this.queryText.replaceAll('sample', userquery);
}
我尝试了许多不同的报价变体,使用这个我没有收到错误消息,但如果我选择 1 个值,我不会从数据库中获得任何数据,但如果我选择至少 2 个值,我会获得最后选择的值数据。
如果我取消注释其中一个额外的引用脚本行,则会收到如下语法错误:
以下项目有错误: 表(id = 597): + 处理过程中发生异常。有关详细信息,请参阅以下消息:无法为 数据集:组织 无法获取结果集元数据。 org.eclipse.birt.report.data.oda.jdbc.JDBCException:SQL 语句不返回 ResultSet 对象。 SQL 错误 #1:You have an error in 你的 SQL 语法;检查与您的 MySQL 对应的手册 在“rudolfs.sviklis”附近使用正确语法的服务器版本, 'sample' )' 在第 25 行; com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException:您的 SQL 语法有错误;检查对应的手册 您的 MySQL 服务器版本,以便在附近使用正确的语法 'rudolfs.sviklis', 'sample' )' 在第 25 行
另外,我应该告诉您,我正在通过查看工作示例来执行此操作。一切都是一样的,前面的代码导致了同样的语法错误,我把它改成了这个脚本,它的作用是一样的。 该示例可在此处获得: http://developer.actuate.com/community/forum/index.php?/files/file/593-default-value-all-with-multi-select-parsmeter/
如果有人能给我一个线索,让我知道我应该做什么,那就太好了。
【问题讨论】: