我有一个 Jasper 报告,它以 Where 子句作为参数:
我通过的 where 子句是:
WHERE vw.computer_number IN ("12635, 34657, 35477")
当我在 IReport 中预览报告时,它返回所有 3 个页面,其中每个页面 id = 在 IN() 中指定的计算机编号。
但是当我在 HashMap 中传递相同的参数时,它只返回一个带有第一个计算机编号的页面。
参数定义:
<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 + ")");