Parameters 需要一个JasperReports null参数值来显示所有

Parameters 需要一个JasperReports null参数值来显示所有,parameters,null,jasper-reports,optional,Parameters,Null,Jasper Reports,Optional,我解决这个问题已经有一段时间了,希望你能帮助我 我有一个关于iReport的报告,我希望即使某些参数为空,也能填写该报告 这是我的 SELECT evento."titulo" AS evento_titulo, evento."data_inicio_realizacao" AS evento_data_inicio_realizacao, evento."data_fim_realizacao" AS evento_data_fim_realizacao, e

我解决这个问题已经有一段时间了,希望你能帮助我

我有一个关于iReport的报告,我希望即使某些参数为空,也能填写该报告

这是我的

SELECT
    evento."titulo" AS evento_titulo,
    evento."data_inicio_realizacao" AS evento_data_inicio_realizacao,
    evento."data_fim_realizacao" AS evento_data_fim_realizacao,
    evento."id" AS evento_id
FROM
    "public"."evento" evento
WHERE
    evento."id" = $P{eventoid} OR
    evento."data_inicio_realizacao" BETWEEN $P{data1} AND $P{data2}
我希望WHERE子句是可选的,也就是说,如果我将这些参数保留为null(或者在id的情况下为0值),我希望获得所有值,而不是一个空白报告

可能吗?我发现一些人制作了一个$P{WHERE_子句},并将整个WHERE子句作为其值传递,但这对我不起作用

事件:“数据不完整” 在$P{data1}和$P{data2}之间

试着替换这个

( (evento.“data_inicio_realizao”>=$P{data1}或$P{data1}为空) 或
(evento.“data_inicio_realizao”我更努力了一点,通过在$p{}参数中传递整个WHERE子句,找到了如何使它工作的方法

我只是删除了整个WHERE条款,并将其放在:

$P!{whereClause}
我在其中放了一个参数,并从报告中删除了三个参数$p{eventoid}、$p{data1}和$p{data2}

我正在使用SpringMVC,在我的类控制器中,在该页面的POST请求映射下,我添加了一个名为whereClause的字符串变量,并将其值设置为“WHERE 1=1”(如果愿意,也可以设置为true):

String whereClause=“其中1=1”;
if(relIndice.getEventoId()!=0){
whereClause+=”和evento.id=“+relIndice.getEventoId().toString();
}
if(relIndice.getData1()!=null){
whereClause+=”和evento.data_inicio_realizao>='“+relIndice.getData1().toString()+”;
}
if(relIndice.getData2()!=null){

whereClause+=“和evento.data\u inicio\u realizao您可以这样做,而不是现在使用的动态sql

select xxx
from <table>
where $P{eventoid} is null or evento."id" = $P{eventoid}
选择xxx
从…起
其中$P{eventoid}为null或evento。“id”=$P{eventoid}

很抱歉回复了这么旧的帖子…

回复帖子永远不会太晚。谢谢你的帮助。
select xxx
from <table>
where $P{eventoid} is null or evento."id" = $P{eventoid}