0

I'm trying to pass a parameter from Java to a subreport. The problem is when I got to check all the values inside an IN. The parameter $P{Itens} is coming on this format(1234,5678,9012) and it's String.

Image from JasperSoft

How can I solve it?

Alex K
  • 22,315
  • 19
  • 108
  • 236
  • 1
    Possible duplicate of [passing SQL "IN" parameter list in jasperreport](https://stackoverflow.com/questions/6226447/passing-sql-in-parameter-list-in-jasperreport) – Alex K May 13 '18 at 17:11

1 Answers1

1

You should pass the parameter type as List from Java to report carrying all possible values. Afterwards, edit your report jrxml and set parameter $P{Itens} datatype to java.util.List instead of String.

In report query, replace iae.COD_PECA in $P{Itens} with $X{IN, iae.COD_PECA, $P{Itens}}. Here, $X{} is a built-in support provided by JasperReports for SQL clause functions.

sdman
  • 146
  • 5
  • Thanks a lot! That worked perfectly! On my aplicattion I must pass the parameters in ArrayList as well, right? – Bruno Ienne May 08 '18 at 18:59
  • Happy to help! Please mark it as accepted answer and yes, you must pass the values in `java.util.Collection` (ArrayList is fine) to report. – sdman May 08 '18 at 19:13