在 jasperreport 中传递 SQL“IN”参数列表
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6226447/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
passing SQL "IN" parameter list in jasperreport
提问by Priyanka
I am working on Jasper Reports and my query uses SQL 'IN' predicate.
我正在研究 Jasper Reports,我的查询使用 SQL 'IN' 谓词。
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.
这里的角色参数可以有 1 个或多个整数值,并且会在生成 jasper 报告时动态决定。
Can anybody please help me on how to set the value of 'roles' parameter thru Java program dynamically.
任何人都可以帮助我了解如何通过 Java 程序动态设置“角色”参数的值。
回答by Aaron Digulla
回答by mikk3l
To complement @Aaron response, you can configure a list parameter ("roles" in your case) within JasperSoft Studio as follows:
为了补充@Aaron 响应,您可以在 JasperSoft Studio 中配置一个列表参数(在您的情况下为“角色”),如下所示:
回答by Junior Tada
Jasper Report has a special variable $X for that:
Jasper Report 有一个特殊的变量 $X 用于:
select * from customer where $X{IN,customer_role,roles}