在jasper ireport中传递空字段作为参数 [英] passing empty field as parameter in jasper ireport

查看:83
本文介绍了在jasper ireport中传递空字段作为参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

查询

select * from db_accessadmin.customerSummary 
where 
(accountNumber = $P{accountNo} or $P{accountNo}='')
and (ppuserMobile = $P{mobileNo} or $P{mobileNo}='')
and ( ppuserStaticID = $P{customerId} or $P{customerId} = '')
and (cast(requestDate as date) between (cast($P{fromDate} as date)) and (cast($P{toDate} as date)))

目的是根据参数值在jasper中生成报告。当参数'fromDate'和'toDate'为空时,查询应该拉出DB中的整个行。
如何修改查询,使其接受'fromDate'和'toDate'的空值。

The aim is to generate a report in jasper depending on the values of the parameters. When the parameters 'fromDate' and 'toDate' are empty , the query should pull out the entire rows in the DB. How can I modify the query so that it accepts null values for 'fromDate' and 'toDate'.

XML文件

<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports"     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="customerSummary2" language="groovy" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="d23efc9c-641e-4e8a-bb9e-25673ee5c713">
<property name="ireport.zoom" value="1.610510000000001"/>
<property name="ireport.x" value="0"/>
<property name="ireport.y" value="0"/>
<parameter name="accountNo" class="java.lang.String"/>
<parameter name="mobileNo" class="java.lang.String"/>
<parameter name="customerId" class="java.lang.String"/>
<parameter name="fromDate" class="java.util.Date">
    <defaultValueExpression><![CDATA[new Date()]]></defaultValueExpression>
</parameter>
<parameter name="toDate" class="java.util.Date">
    <defaultValueExpression><![CDATA[$P{fromDate}+7]]></defaultValueExpression>
</parameter>
<queryString>
    <![CDATA[select * from db_accessadmin.customerSummary where (accountNumber =         $P{accountNo} or $P{accountNo}='')
 and (ppuserMobile = $P{mobileNo} or $P{mobileNo}='')
 and ( ppuserStaticID = $P{customerId} or $P{customerId} = '')
 and (cast(requestDate as date) between (cast($P{fromDate} as date)) and (cast($P{toDate} as date)))]]>
</queryString>


推荐答案

只有当我在jasper中设计报表时才会出现此问题iReport的。但是一旦我在服务器中部署它,问题就解决了。服务器接受空值。

This issue only occurs when i design the report in jasper iReport. But once i deploy it in the server, the issue is resolved. The server accepts null values.

这篇关于在jasper ireport中传递空字段作为参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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