uouser Posted January 25, 2012 Share Posted January 25, 2012 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 tableWhere 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 More sharing options...
augarte Posted January 25, 2012 Share Posted January 25, 2012 Hi, For using parameteres in your queries you need to reference them in a different way. Try putting this in your query:SELECT parameter from tableWhere parameter1 IN ($P!{collection_input}.toString())This should work.Hope this helps.Regards. Link to comment Share on other sites More sharing options...
uouser Posted January 26, 2012 Author Share Posted January 26, 2012 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 More sharing options...
augarte Posted January 26, 2012 Share Posted January 26, 2012 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 More sharing options...
cgrove Posted February 2, 2012 Share Posted February 2, 2012 Hello,I had this same issue. Collections need to be delt with differently in your sql. Try this: SELECT parameter from tableWhere $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 ENTDATFROM "XXXXXX"."REMKL001" REMKL001WHERE $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 More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now