Reputation: 925
The requirement is to generate a single report connecting to a single DB:
Both these queries need results based on a WHERE
clause, which is supplied dynamically.
Can somebody point me to some examples on how to achieve this?
Thank you.
Upvotes: 3
Views: 6784
Reputation: 31171
You can tell JasperReports to use a parameter to define part of the query using the $P!{PARAMETER_NAME}
syntax. This tells JasperReports to use the literal value of PARAMETER_NAME
as part of the query. You can then do:
WHERE_CLAUSE
in the report.WHERE_CLAUSE
a default value of 1=1
.
SELECT * FROM table WHERE $P!{WHERE_CLAUSE}
The $P!
expression changes the literal SQL statement to:
SELECT * FROM table WHERE 1=1
That is a valid query. Note the difference between $P{}
and $P!{}
-- the exclamation mark (!
) is important.
You can then supply the SQL conditions dynamically.
Upvotes: 3