I am working on Jasper Reports and my query uses SQL 'IN' predicate.
SELECT customer_name AS NAME,
id_customer AS ID
FROM customer
WHERE customer_role IN ($P{roles})
Here the role parameter can have 1 or more integer values and will be dynamically decided when generating the jasper report.
Can anybody please help me on how to set the value of 'roles' parameter thru Java program dynamically.
The examples linked to in the accepted answer don't come up for me.
An alternative that worked for me is instead of using:
...
WHERE customer_role IN ($P{roles})
I used this:
...
WHERE customer_role IN ($P!{roles})
And for the roles
variable I pass in a String containing one or more values, each in single quotes, separated by commas (e.g., '1','2','3'
).
See here for reference.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With