klin0011 Posted April 14, 2010 Share Posted April 14, 2010 Hi,I am trying to run a report with a multi-select parameter in iReport 3.7 but cannot get it to run.Parameter name is List of type java.util.Collection.I have a column in my database called "id" of type int.I passed the parameter value to the query like this:SELECT id, nameFROM metadataWHERE $X{IN, id, List}I get error messages for executing SQL statment.Any ideas on how to solve this? Link to comment Share on other sites More sharing options...
ckampshoff Posted April 15, 2010 Share Posted April 15, 2010 Hi,Which error message do you get? And where did you get it?Regards Christina Link to comment Share on other sites More sharing options...
klin0011 Posted April 15, 2010 Author Share Posted April 15, 2010 Hi Christina, there is only a very big java stack trace saying the sql statement is wrong. The statementSELECT id,name FROM metadata WHERE $X{IN, id, List} is expanded to:SELECT id,name FROM metadata WHERE id IN([1,2]) And the stack trace in the sql classes say something like: "[" error in sql statement. The Collection List is filled from another sql statement with id from type Integer. Therefore an "Input Datatype" was defined. When printing the parameter in the main report we get something like [1,2,3,4]. When we change the sql query manually to SELECT id,name FROM metadata WHERE id IN(1,2) everything is working fine. RegardsIngrid Link to comment Share on other sites More sharing options...
ckampshoff Posted April 16, 2010 Share Posted April 16, 2010 Hi Ingrid,that sounds like something is wrong with the filling of the parameter. A java.util.collection is always printed with the leading "[" and an ending "]" (if you print it via iReport). What about trying to cut off the [ ] before filling the parameter of the SQL-Query?RegardsChristina. Link to comment Share on other sites More sharing options...
klin0011 Posted April 16, 2010 Author Share Posted April 16, 2010 Hi Christinaif I use this query in iReport:SELECT id, name FROM metadata WHERE $X{IN, id, List}I get the following errors: Code Post Edited by klin0011 at 04/16/2010 13:47 Link to comment Share on other sites More sharing options...
klin0011 Posted April 16, 2010 Author Share Posted April 16, 2010 I tried is also with this query in iReport:SELECT id, name FROM metadata WHERE id IN( $P!{Messpunkt})and than I get this errors: Code: RegardsIngridPost Edited by klin0011 at 04/16/2010 13:57 Link to comment Share on other sites More sharing options...
ckampshoff Posted April 19, 2010 Share Posted April 19, 2010 Hi Ingrid,I think it has something to do with the filling of your collection. It seems to me that there are no Integer values in the collection ("Operator existiert nicht: integer = character varying"). The same would cause the other error ("Syntaxfehler bei »[«"). How is the collection (you use in your query) filled? I never had such problems (errors) when I used a collection for a multi-select parameter.RegardsChristina. Link to comment Share on other sites More sharing options...
klin0011 Posted April 19, 2010 Author Share Posted April 19, 2010 Hi Christina,I added the parameter "List" at the input data types at the server. The properties for "List" are :Name and Label: ListInput Control Details: -Type: Multi-select Query(Check Box) -Query Resource: Locally defined -The query (SQL): select id, name from metadata; -The locally defined datasource is my postgresql -Value Column: id -Visible query column: idIn the database "id" is defined as an Integer. I don't know if it's possible to define somewhere the type of "id", so that the collection can be filled with Integer-values.RegardsIngrid Link to comment Share on other sites More sharing options...
ckampshoff Posted April 20, 2010 Share Posted April 20, 2010 Hi,I work on an oracle database with iReport 3.6.0 and jasperserver 3.5. I have multi-select querys for many reports and parameters on the jasperserver. I implemented the multi-selects with String and with BigDecimal and they work. I don't think that it won't work with Integer. I 'll do a test on it.You can change the field types of the database fields in iReport. Go in the Report Inspector to Fields. There you can select the Field Class in the properties of the selected field. If you change something in the query and retrieve the new fields automatically from the db, it would revert your changes.RegardsChristina. Link to comment Share on other sites More sharing options...
matusz84 Posted August 20, 2010 Share Posted August 20, 2010 Hello,I work on an mysql, this fix my problem:id_pers in (select replace(replace("$P!{id_pers_list}","[",""),"]","")) RegardsMateuszPost Edited by matusz84 at 08/20/2010 13:48 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