我有一个Jasper报告,其中Where子句作为参数:
我传递的where子句是:
WHERE vw.computer_number IN ("12635, 34657, 35477")
当我在IReport中预览报表时,它返回所有3个页面,其中每个页面id =在IN()中指定的computer_number。
但是当我在HashMap中将它作为参数传递时,它只返回带有第一个计算机编号的1页。
参数定义:
<parameter name="paySlipWhereClause" class="java.lang.String" isForPrompting="false">
<defaultValueExpression>
<![CDATA[" Where vw.computer_number IN(12635, 34657, 35477)"]]>
</defaultValueExpression>
</parameter>
构建参数值的Java代码:
String computer_numbers[] = {"12635", "34657", "3547"};
String computer_nos = "";
for (int i = 0; i < computer_numbers.length; i++) {
computer_nos = computer_nos + "," + computer_numbers[i];
}
String comp_numbers = computer_nos.replaceFirst(",", "");
HashMap param = new java.util.HashMap<String, String>();
param.put("payroll_tag", payroll_tag);
//" WHERE vw.computer_number IN (29875,31775,29929)"
param.put("paySlipWhereClause", "WHERE vw.computer_number IN (" + comp_numbers + ")");