Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
DataSource events Adapter example
VinceG
I am planning on creating a custom Datasource event adapter where I have specific actions done for the event AfterOpen and beforeClose.<br />
I am looking for examples of code that would explain how to call a stored procedure within the DataSourceEventAdapter inherited class.<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>public class Login extends DataSourceEventAdapter {
public void afterOpen(IDataSourceInstance dataSource, IReportContext reportContext){
[b]// Call some stored procedure here. how?[/b]
}
}</pre>
<br />
Thanks for any suggestions you might have.
Find more posts tagged with
Comments
mwilliams
If you want to run your stored procedure in script, you'll probably need to create the connection to your database in script and call the stored procedure with that connection. What are you trying to do in the dataSource that you need to call stored procedures not in the dataSet for report data?
VinceG
Thanks so much for responding. I have been struggling on that issue for few days now already.<br />
<br />
<blockquote class='ipsBlockquote' data-author="'mwilliams'" data-cid="81100" data-time="1312468233" data-date="04 August 2011 - 07:30 AM"><p>
If you want to run your stored procedure in script, you'll probably need to create the connection to your database in script and call the stored procedure with that connection.</p></blockquote>
Would it be a new connection then, different than the other one used by others Datasets? I need to have only one unique connection created by each report. <br />
I thought of other options:<br />
1) Create a custom JDBC class that inherits the JDBC BIRT one where I can call stored proc right after connection is made?<br />
2) Somehow store the connection object into a report session variable that I can use in JS to execute SQL statement.<br />
3) Force to execute a dataset earlier. Is that possible? I think BIRT does not support yet forcing the execution order of the DataSets, right?<br />
<br />
<blockquote class='ipsBlockquote' data-author="'mwilliams'" data-cid="81100" data-time="1312468233" data-date="04 August 2011 - 07:30 AM"><p>
What are you trying to do in the dataSource that you need to call stored procedures not in the dataSet for report data?<br /></p></blockquote>
<br />
I am trying to call a stored procedure that will log in DB the time the report execution starts. So I need to call that Stored proc at the very beginning.
VinceG
Update: getting some progress. The following link helped a lot:<br />
<br />
<a class='bbc_url' href='
http://www.birt-exchange.org/org/forum/index.php/topic/22593-calling-a-stored-procedure/page__s__9b2d0cde65a6916e94afd096da17236d'>http://www.birt-exchange.org/org/forum/index.php/topic/22593-calling-a-stored-procedure/page__s__9b2d0cde65a6916e94afd096da17236d</a><br
/>
<br />
One issue with the example is that it creates a new datasource (connection) because code is in beforeFactory trigger, in my case it would be in afterOpen of the Datasource so that dataset can run on the same connection.<br />
<br />
I need something like:<br />
dataEngine.defineDataSource ( reportContext.getDesignHandle().findDataSource("MyDATASOURCE")) but that doesn't work.<br />
<br />
Thanks for any feedback.
balconsult
<p>Vince, </p>
<p>Did you get anywhere with this? I am trying to do a similar thing and it is a requirement that I be using the same database session.</p>
<p> </p>
<p> </p>