Collection parameter problem: $X{}

0
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
$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:
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. As i understood,for jasperserver, casted "diam" is always exist in "DiamRQn" collection, although everything went ok for ireport !
Plz check out the attachement
Additional inf:
DBMS: postgresql
ireport ver: 5.0.1
khaled_khlifi's picture
Joined: May 31 2013 - 7:30am
Last seen: 4 years 11 months ago

2 Answers:

0

Try changing the type of the parameter, maybe DiamRQn is passed as a set of string and not numbers

m.longo's picture
52
Joined: Oct 24 2012 - 4:42am
Last seen: 1 week 6 days ago

Thank you for replying, but the class of DiamRQn is java.util.Collection, when i set It to java.util.Collection<Short> , it not working,
when cast the query of the collection
select distinct cast("Diam" as smallint) from ...
also not working
the solution mentioned in the question, work but shows all possible value of "Diam" ! and this is the problem

khaled_khlifi - 6 years 5 months ago

Thank you for replying, but the class of DiamRQn is java.util.Collection, when i set It to java.util.Collection<Short> , it not working,
when cast the query of the collection
select distinct cast("Diam" as smallint) from ...
also not working
the solution mentioned in the question, work but shows all possible value of "Diam" ! and this is the problem

khaled_khlifi - 6 years 5 months ago
0

Are you sure, that the parameter "

DiamRQn</span><span style="font-family: monospace;">" </span>gets any values at all on jasperserver? Giving back all possible values is typically a problem, if the passed list is empty (in this case, the whole $X{...} clause is removed from the query...)</p>
<p>Cheers, Thomas</p>
<p>http://www.thomaszimmer.net</p>

Thomas Zimmer's picture
Joined: Oct 2 2012 - 1:35am
Last seen: 5 days 11 hours ago

Thank you Thomas,
the request of "DiamRQn" is tested in the DBMS,and if jasperserver fail to execute the request how he shows all the values ? as i undestand, everthing went ok exept the $x{}, jasperserver fail to choose only the selected values but he have all of them,
thank you anyway :)

khaled_khlifi - 6 years 5 months ago
Feedback