多个参数值 [英] Multiple parameter values

查看:142
本文介绍了多个参数值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我正在使用BIRT 2.6.2和eclipse。

我在BIRT中遇到问题,

我试图从级联参数组最后一个参数JDSuser中放置多个值。该参数被允许有多个值,我正在使用列表框。



为了能够做到这一点,我正在写我的sql查询与where-in语句我用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
左边连接组织
organization.id = jamacomment.organizationId

上附加文档document.id = jamacomment.documentId
在$ b上加入user_role $ b user_role.userId = userbase.id
右侧连接角色
role.id = user_role.roleId

其中jamacomment.scopeId = 11
和r ('sample grupa')中的ole.name
和('sample')中的userbase.userName



  if(params [JDSuser]。value [ 0]!=(所有用户)){
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:在
中您的SQL语法有错误;检查对应于您的MySQL
服务器版本的手册,以便在第25行使用rudolfs.sviklis附近的正确语法,
'sample')'
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-选择parsmeter /



如果有人可以给我至少一个线索,我应该做什么,这将是伟大的。

解决方案

您应该始终使用参数的value属性,即:

  var users = params [JDSuser]。value; 

没有必要用引号括住userquery,因为这些引号已经放在SQL查询中arround'sample'。另外还有一个错误,因为userquery还没有被定义在行:

  var userquery = userquery + users.join(', ); 

这可能会在您的查询中引入一个null字符串。因此删除所有对userquery变量的引用,只需在最后使用这个表达式:

  this.queryText = this.queryText.replaceAll 'sample',users.join(',')); 

注意我删除了连接表达式中的空格。最后,一旦它工作得很好,您可能需要通过测试值为null来使您的报告输入更强大:

  if( params [JDSuser]。value!= null&& params [JDSuser]。value [0]!=(所有用户)){
// Do stuff ...

}


I have a problem with BIRT when I try to pass multiple values from report parameter.

I'm using BIRT 2.6.2 and eclipse.

I'm trying to put multiple values from cascading parameter group last parameter "JDSuser". The parameter is allowed to have multiple values and I'm using list box.

In order to be able to do that I'm writing my sql query with where-in statement where I replace text with javascript. Otherwise BIRT sql can't get multiple values from report parameter.

My sql query is

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' )

and my javascript code for that dataset on beforeOpen state is:

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);
}

I tryed many different quote variations, with this one I get no error messages, but if I choose 1 value, I get no data from database, but if I choose at least 2 values, I get the last chosen value data.

If I uncomment one of those additional quote script lines, then I get syntax error like this:

The following items have errors: Table (id = 597): + An exception occurred during processing. Please see the following message for details: Failed to prepare the query execution for the data set: Organization Cannot get the result set metadata. org.eclipse.birt.report.data.oda.jdbc.JDBCException: SQL statement does not return a ResultSet object. SQL error #1:You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'rudolfs.sviklis', 'sample' )' at line 25 ; com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'rudolfs.sviklis', 'sample' )' at line 25

Also, I should tell you that i'm doing this by looking from working example. Everything is the same, the previous code resulted to the same syntax error, I changed it to this script which does the same. The example is available here: http://developer.actuate.com/community/forum/index.php?/files/file/593-default-value-all-with-multi-select-parsmeter/

If someone could give me at least a clue to what I should do that would be great.

解决方案

You should always use the value property of a parameter, i.e.:

var users = params["JDSuser"].value;

It is not necessary to surround "userquery" with quotes because these quotes are already put in the SQL query arround 'sample'. Furthermore there is a mistake because userquery is not yet defined at line:

var userquery = userquery + users.join("', '");

This might introduce a string such "null" in your query. Therefore remove all references to userquery variable, just use this expression at the end:

this.queryText=this.queryText.replaceAll('sample', users.join("','"));

Notice i removed the blank space in the join expression. Finally once it works finely, you probably need to make your report input more robust by testing if the value is null:

if( params["JDSuser"].value!=null && params["JDSuser"].value[0] != "(All Users)" ){
  //Do stuff...

}

这篇关于多个参数值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆