0

我的报告基于此请求:

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”字段是一个smallint,问题出在这部分

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

DiamRQn 是控制输入使用的参数,它是来自请求的多项选择,当删除铸造时它说:

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

在 ireport preview 中投射它可以正常工作,但在 jasperserver 上,图表显示“Diam”的所有值,选中和未选中。据我了解,对于 jasperserver,铸造的“diam”始终存在于“DiamRQn”集合中,尽管 ireport 一切正常!

附加信息:DBMS:postgresql ireport 版本:5.0.1

4

2 回答 2

0

在 Jasper 中使用 $IN{} 语句执行功能之前,我遇到了一些问题。我的解决方案通常是先执行函数,然后执行 $IN{} 语句。我通常在子选择中执行我需要执行的任何功能,然后在它之外执行 $IN{} 语句。所以你可以试试这个:

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"

我可能还会将部分 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"
于 2013-06-10T14:29:47.293 回答
0

听起来输入控件正在返回 varchar 类型的值(char 变化)。是否可以将输入控件的查询/列表源更改为返回 smallint 类型的值?然后也许您可以删除该CAST功能,希望一切都会好起来。

于 2013-06-10T19:34:28.540 回答