简体   繁体   English

IReport,Jasperserver:同一份报告的结果不同

[英]IReport, Jasperserver: different result for the same report

My report based in this request: 我的报告基于此请求:

select "Annee" ,"Diam", sum("Consommation") from "Consom_N","CptDim"
where "Annee" >= $P{a1} and "Annee" <= $P{a2} 
and "Consom_N"."NumCpt"="CptDim"."NumCpt"and "District"= $P{dst}
and $X{IN, cast("Diam" as character varying), DiamRQn}
group by "Annee","Diam"
order by "Annee"
;

"Diam" field is a smallint, the problem is in this part “直径”字段是smallint,问题就在这部分

$X{IN, cast("Diam" as character varying), DiamRQn}

DiamRQn is the parameter used by the control input wich is a multiple selection from request, when remove casting it says: DiamRQn是控制输入使用的参数,从请求中是多个选择,删除转换时显示:

PSQLException: ERROR: operator does not exist : smallint = character varying

with casting it work fine in ireport preview , but on the jasperserver, the chart shows all the values of "Diam", the selected and the not selected. 通过投射,它可以在ireport预览中正常工作,但是在jasperserver上,该图表显示了“直径”的所有值,已选中和未选中。 As i understood,for jasperserver, casted "diam" is always exist in "DiamRQn" collection, although everything went ok for ireport ! 据我了解,对于jasperserver,强制转换的“ diam”始终存在于“ DiamRQn”集合中,尽管对于ireport来说一切正常!

Additional inf: DBMS: postgresql ireport ver: 5.0.1 附加信息:DBMS:PostgreSQL ireport版本:5.0.1

I have had some problems before performing functions with the $IN{} statement in Jasper. 在Jasper中使用$ IN {}语句执行功能之前,我遇到了一些问题。 My solution is usually to perform the function first, the doing the $IN{} statement after. 我的解决方案通常是先执行该功能,然后再执行$ IN {}语句。 I usually do whatever function I need to do within a sub-select, and then do the $IN{} statement outside of it. 我通常会在子选择中执行我需要执行的所有功能,然后在其外部执行$ IN {}语句。 So you could try this: 因此,您可以尝试以下操作:

SELECT *
FROM
(
SELECT "Annee" ,"Diam", sum("Consommation"),
       cast("Diam" as character varying) AS Diam_char
FROM   "Consom_N","CptDim"
WHERE  "Annee" >= $P{a1} and "Annee" <= $P{a2} 
       and "Consom_N"."NumCpt"="CptDim"."NumCpt" and "District"= $P{dst}
GROUP BY "Annee","Diam"
) x
WHERE  $X{IN, Diam_char, DiamRQn}
ORDER BY "Annee"

I would probably also move part of your where clause into a join between the Consom_N and CptDim tables, but that's optional. 我可能还会将您的where子句的一部分移到Consom_N和CptDim表之间的联接中,但这是可选的。

SELECT *
FROM
(
SELECT "Annee" ,"Diam", sum("Consommation"),
        cast("Diam" as character varying) AS Diam_char 
FROM   "Consom_N"
       JOIN "CptDim" ON "Consom_N"."NumCpt"="CptDim"."NumCpt" 
WHERE  "Annee" >= $P{a1} and "Annee" <= $P{a2} 
       and "District"= $P{dst}
GROUP BY "Annee","Diam"
) x
WHERE  $X{IN, Diam_char, DiamRQn}
ORDER BY "Annee"

It sounds like the input control is returning values of type varchar (char varying). 听起来输入控件正在返回varchar类型的值(可变char)。 Is it possible to change the query/list source of the input control to return values of type smallint? 是否可以将输入控件的查询/列表源更改为返回smallint类型的值? Then perhaps you could remove the CAST function and hopefully all would be well. 然后,也许您可​​以删除CAST函数,希望一切都很好。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM