JasperReports: How to add a WHERE statement in SQL query depending on a Boolean parameter?

前端 未结 3 966
刺人心
刺人心 2021-01-24 04:34

How can I add a sub where statement in SQL if my Boolean parameter is true in JasperReports?
For example, I have my SQL as below:

SELECT * FROM shop         


        
3条回答
  •  野性不改
    2021-01-24 05:03

    You can do that direct in SQL

    SELECT * FROM shops WHERE region = "Canada"
    AND (@param <> `True` OR isActive = 'Y')
    -----^^^^^^^^^^^^^^^^--<< Condition: Your param is not true------
    ORDER BY name
    

提交回复
热议问题