Dynamic Parameters


What is dynamic parameters?
Its a list of values, generated by a sql query, this list of values can be single selected (normal combobox with list of values), or multi select (list of values on two boxes of values where user can pick more then one item)

How to create a dynamic parameter on my report (iReport)?
This dynamic parameter will only work when viewed from JasViewer, but you can create them on you iReport, in order to do that you need to:

1 - Create a new parameter of type Integer (for single-select) or type String (for multi-select)

2 - On the parameter create new propertiy called "query_sql", where the value will be your sql code ex.: "SELECT idcar, license_plate FROM cars" (quotation marks are need), the sql code must return two columns first will be the value (usually an id) and the second a description.

3 - Edit your SQL query on your iReport, to receive the parameter you created (ex.: SELECT * FROM friends WHERE idfriend = $P{Friends} THIS IS A SINGLE-SELECT EXAMPLE) the parameter $P{Friend} will return the value of the first column
(ex.: SELECT * FROM friends WHERE idfriend IN ($P!{sql_Friends}) THIS IS A MULTI-SELECT EXAMPLE) please notice the exclamation point on parameter, it is necessary


Home: Home