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
Share
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
beforeOpenon 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.