外部化 BIRT 查询
有没有办法外部化 BIRT 报告的报告查询。我们需要支持多个数据库引擎,因此我们的查询根据底层数据库的不同而不同。我想使用配置参数来告诉 BIRT 报告使用特定的查询文件
Is there a way to externalize report queries for BIRT reports. We need to support multiple database engines and so our queries are different depending on the underlying database. I would like to use a config parameter to tell BIRT report to use a specific query file
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
当然可以。如果您在报告本身中编写一些 JavaScript,它可以访问磁盘上的文件以检索文本查询并在执行之前修改查询。
您需要为其编码的事件是数据源上的
beforeOpen
。实际上,我们通过检测通配符参数是否设置为"*"
并动态调整 SQL 查询,将其从: 更改为:
丑陋的修改只是为了让我们不必担心改变位置参数。
您可以从磁盘文件中读取一行并使用以下内容更改查询:
尽管您可能应该有比这更好的错误检查:-)我删除了它,因为它(1)有点大; (2) 具有一定的专有性。
Sure you can. If you code up some Javascript in the report itself, it can access files on the disk to retrieve the textual queries and modify the query before it's executed.
The event you need to code for is
beforeOpen
on the data source. We actually use this for wildcarding parameters by detecting if they're set to"*"
and dynamically adjusting the SQL query, changing it from:to:
The ugly modification is just so we don't have to worry about changing the positional parameters.
You can read a line from a disk file and change the query with something like:
although you should probably have better error checking than that :-) I removed it as it's (1) somewhat large; and (2) somewhat proprietary.
我不知道有什么方法可以开箱即用地做到这一点。您可能会想象一些相当复杂的脚本来在数据集的 onLoad 事件上触发。
在每个数据库中放置相同的存储过程怎么样?然后,您可以参数化数据连接信息(在报表数据源的编辑页面上)并动态指示报表查询特定数据源。只要存储过程位于所有实例上,您就可以从正确的源获取正确的数据。
I do not know of a way to do this out of the box. You could probably dream up some fairly complex scripting to fire off on the onLoad event of the Data Set.
How about placing the same stored procedure in each DB? THen you can parameterize the data connection information (On the Edit page for the report Data Source) and dynamically direct your report to query a specific data source. As long as the stored proc is on all instances, you will get the correct data from the correct source.