Filter BIRT JDBC Query
Options
<p>There is a ServerUserName variable in the AppContext that gets passed to the engine tasks/report scripts. You can design a report with a parameterized JDBC query and the parameter can be bound to an expression that is a function of the ServerUserName in AppContext. Since this parameter only gets passed when it is ran on the iServer, the expression will need to check if it exists first, if yes, use it to set the JDBC query parameter value.</p>
<p>In the beforeOpen method of the data set you can access the appContext, which is a HashMap, from the report context. Get the object from the Map using the key ServerUserName. Here is sample code that illustrates how you could filter the query in the beforeOpen method:</p>
<p><span style=\"font-family: Courier New,Courier,monospace;\">
<div class=\"xoopsCode\" style=\"border: 1px solid;\">
<p><span style=\"font-family: Courier New,Courier,monospace;\">myMap = reportContext.getAppContext();<br />usr = myMap.get(\"ServerUserName\");<br />if(usr != null)<br />{ <br /> this.queryText = this.queryText + \" WHERE userid = \''\" + usr + \"\''\" <br />}</span></p>
</div>
</span></p>
<p>In the beforeOpen method of the data set you can access the appContext, which is a HashMap, from the report context. Get the object from the Map using the key ServerUserName. Here is sample code that illustrates how you could filter the query in the beforeOpen method:</p>
<p><span style=\"font-family: Courier New,Courier,monospace;\">
<div class=\"xoopsCode\" style=\"border: 1px solid;\">
<p><span style=\"font-family: Courier New,Courier,monospace;\">myMap = reportContext.getAppContext();<br />usr = myMap.get(\"ServerUserName\");<br />if(usr != null)<br />{ <br /> this.queryText = this.queryText + \" WHERE userid = \''\" + usr + \"\''\" <br />}</span></p>
</div>
</span></p>
0
Categories
- All Categories
- 109 Developer Announcements
- 49 Articles
- 100 General Questions
- 122 IM Services
- 40 OpenText Hackathon
- 31 Developer Tools
- 20.6K Analytics
- 4.1K AppWorks
- 8.9K Extended ECM
- 897 Cloud Fax and Notifications
- 77 Digital Asset Management
- 9.3K Documentum
- 29 eDOCS
- 122 Exstream
- 39.8K TeamSite
- 1.7K Web Experience Management