How to get entire report by using one parameter in jasper report?

0

my table have columns id , Category , City,Quantity, UnitPrice etc. I want to get my entire report using one parameter $P={City}(SQL dynamic query for jasperreport) like when I will pass ALL value to parameter $P={City} it should have to show my entire report what I was doing previously was tried doing it with another parameter but its wrong i guesss

Select * from sales where City=$P{City} or $P{ALLL} is not null


but then whenever I will pass any value in all it will give entire report which is wrong way 

tejaswini.patil2000's picture
Joined: Jul 8 2021 - 2:59am
Last seen: 2 months 1 week ago

1 Answer:

0

I will tell you that I may not understand your requirements.

 

In the following SQL case, if a value is entered for the single value parameter 'P_City', the data will be retrieved with the entered condition.
If no value is entered for the single value parameter 'P_City', all data will be retrieved.

SELECT * FROM sales WHERE (City=$P{P_City}) OR ($P{P_City} IS NULL)

If 'P_City' is a multi-valued parameter (Class=java.util.Collection) instead of a single-valued parameter (Class=java.lang.String), then the SQL will look like this

SELECT * FROM sales WHERE $X{IN, City, P_City}

I hope this is helpful.

yama818's picture
241
Joined: Aug 17 2018 - 3:48pm
Last seen: 1 day 18 hours ago
Feedback
randomness