在 jasper 报告中插入查询
是否可以在报告生成期间在 IReports/jasper 报告中执行“插入查询”?
Is it possible to execute "insert query" in IReports/jasper reports during report generation?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
是的,您需要的想法是使用以下语法的参数:
$P!{PARAM_NAME}
。因此,您的整个 SQL 查询(或其他类型的查询)可以简单地是
$P!{SQL}
。然后您准确地传入您需要的动态 SQL。更新:
读完Sharad的评论后,我意识到我上面的回答不好。我写的是事实……但它没有解决核心问题。
不,您的报表无法真正执行插入语句。严格来说,我确信这并非不可能。您可以在 .jar 文件中添加脚本或自定义函数来建立连接并执行插入。但实际上......一份报告将执行一个或多个查询。 JR 框架并不旨在执行插入或更新。
Yes, the idea you need is parameters using this syntax:
$P!{PARAM_NAME}
.So your entire SQL query (or other type of query) could be simply
$P!{SQL}
. Then you pass in exactly the dynamic SQL that you need.UPDATE:
After reading Sharad's comment, I realized that my answer above is not good. What I wrote is true... but it fails to address the core question.
No, your report cannot really execute an insert statement. Strictly speaking, I'm sure it's not impossible. You could add a scriptlet or custom function in a .jar file that makes a connection and does an insert. But realistically speaking... a report will execute one or more queries. The JR framework is not intended to execute inserts or updates.
是的,你可以。当您想要显示报告时,可以执行查询。这是一个适合我的示例。
Yes you can. You can execute the query when you want to display the report. Here is a sample that works for me.