Search code examples
postgresqljasper-reportsjaspersoft-studio

How to define and use a parameter in Jasper Studio that is a set of ids?


Does anyone know how to define a parameter in Jasper Studio (Community version 6.3.1 final) that is a collection, such as a Set, and to use that in a postgresql query? For example, this Set could be a set of ids that would then be used in the query.

I do a simple sql query like:

select pg_typeof($P{companyDepartmentIds}) as type

Picture of parameter that is a set

I get the following error after selecting "Read Fields":

Error

It seems like this should be possible, I feel I am missing something. I am not sure where in the Jasper Studio interface I can call this setObject() function. Anyone have any thoughts here?

If defining a collection of parameters can't be done, the only other thing I could think of is I could have the parameter be a String, but it would be understood it would be a comma delimited list of values, then I could use regexp_split_to_table or regexp_split_to_array within the query itself.


Solution

  • I was directed to this link and saw what I needed here:

    https://community.jaspersoft.com/blog/tip-multi-select-query-integer-parameter-japser-ireportstudio

    Specifically what I was looking for was this part from the website under the "Correct Way:" example

    SELECT * from table where $X{IN,id,companyDepartmentIds}