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

multi-select parameter in iReport 3.7


klin0011

Recommended Posts

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,
     name
FROM
     metadata
WHERE
    $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

  • Replies 9
  • Created
  • Last Reply

Top Posters In This Topic

Hi Christina,

 

there is only a very big java stack trace saying the sql statement is wrong.

 

The statement

SELECT 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.

 

Regards

Ingrid

 

Link to comment
Share on other sites

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?

Regards

Christina.

Link to comment
Share on other sites

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.

Regards

Christina.

Link to comment
Share on other sites

Hi Christina,

I added the parameter "List" at the input data types at the server.
The properties for "List" are :

Name and Label: List
Input 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: id

In 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.


Regards

Ingrid

Link to comment
Share on other sites

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.

Regards

Christina.

Link to comment
Share on other sites

  • 4 months later...

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...