Jump to content
We've recently updated our Privacy Statement, available here ×

Using java.util.Collection as input parameter


uouser

Recommended Posts

Hi,

 

I have created a new input parameter in my report as java.util.Collection. I am using it in my SQL query as:

SELECT parameter from table

Where parameter1 IN ($P{collection_input}.toString())
 

I am getting error in query designer as 'null.toString()' does not exist. If I don't use toString() then the report just simply doesn't work at all.

 

I tried to search on the forum and couldn't find any help. Does anyone knows how to deal with Collection opbject as input parameter in iReport? Thanks for help in advance.

Link to comment
Share on other sites

  • Replies 4
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Thanks for coming back with a response. I tried this option and I get 'Error: SQL problems: You have an error in your SQL syntax; check the manual that corresponds to your MySQL version for the right syntax to use near toString()' error message.

I am passing all string values in the collection. it seems like it doesn't accept any function called after the parameter.

 

Thanks for the help in advance.

Link to comment
Share on other sites

And which is the value of your Collection? I mean, I undestand all the values in your collection are strings but can you apply toString() function to a Collection? Maybe you have to take the elements of your collection one by one and construct a string in order to use it in your query.

I don't really understand how can you pass a Collection type object to a String type.

Regards.

Link to comment
Share on other sites

 Hello,

I had this same issue. Collections need to be delt with differently in your sql. Try this:

 

SELECT parameter from table

Where $X{ IN, "Data Field" ,"YourParameterName"}

 

In my case my sql is as follows:

SELECT

     REMKL001."RKCTID" AS RKCTID,

     REMKL001."RKCUST" AS RKCUST,

     REMKL001."RKJOBN" AS RKJOBN,

     REMKL001."RKLINE" AS RKLINE,

     REMKL001."RKRQTY" AS RKRQTY,

     REMKL001."RKCODE" AS RKCODE,

     REMKL001."RKEMP1" AS RKEMP1,

     REMKL001."RKEMP2" AS RKEMP2,

     REMKL001."RKSUP" AS RKSUP,

     REMKL001."RKCRMK" AS RKCRMK,

     REMKL001."RKYRMK" AS RKYRMK,

     REMKL001."RKMRMK" AS RKMRMK,

     REMKL001."RKDRMK" AS RKDRMK,

     REMKL001."RKQTY" AS RKQTY,

     REMKL001."RKITEM" AS RKITEM,

     REMKL001."RKISFX" AS RKISFX,

     REMKL001."RKCOLR" AS RKCOLR,

     REMKL001."RKTNET" AS RKTNET,

     REMKL001."RKRNET" AS RKRNET,

     REMKL001."RKRGN" AS RKRGN,

     REMKL001."RKPO" AS RKPO,

     REMKL001."SUPNUM" AS SUPNUM,

     REMKL001."SUPNAM" AS SUPNAM,

     REMKL001."SUPCMT" AS SUPCMT,

     REMKL001."ENTDAT" AS ENTDAT

FROM

     "XXXXXX"."REMKL001" REMKL001

WHERE

     $X{ IN ,RKCODE,RemakeCode}

 AND ENTDAT between $P{BeginDate} and $P{EndDate}

 AND $X{ IN, RKSUP,Supervisor}

ORDER BY

     RKSUP ASC,

     RKCODE ASC

 

 

Hope it helps

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...