Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
THRUST SERVICES & TOOLS
CLOUD EDITIONS
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
Loop a dataSet multiple times
shir
<p>Hi All,</p>
<p> </p>
<p>I am using BIRT RCP 4.3.1 for some report automation.</p>
<p> </p>
<p>Regarding a chart report i get data from ORACLE DB, where the query used has a where clause something as:</p>
<p> </p>
<p>WHERE bus_date between <startDate> and <endDate></p>
<p> </p>
<p>startDate and endDate are report parameters passes by the user.</p>
<p> </p>
<p>However due to the design of the table, the `BETWEEN` clause is taking lot of time and frequently timing out.</p>
<p> </p>
<p>Instead when we are querying like :</p>
<p> </p>
<p>WHERE bus_date = <Date>, this is far quicker.</p>
<p> </p>
<p>Hence i was wondering as how to run this oracle query multiple times in a loop from startDate to endDate and store the result which i can eventually use it in a chart display.</p>
<p> </p>
<p>How can we achieve this?</p>
<p> </p>
<p>I have been working with BIRT for some time now, however never tried out the scripting option in it.</p>
<p> </p>
<p>Can i have a brief about programming in BIRT or some info to get started?</p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
Find more posts tagged with
Comments
Clement Wong
<p>Ideally, you might want to work with your DBA to tune that DB to get the BETWEEN working faster. Otherwise, one suggestion would be to have your DBA create you a stored procedure that would return you the result sets with a UNION of the separate WHERE bus_date clauses.</p>
<p> </p>
<p>However, if you don't have those options, you would be able to programmatically via the BIRT Data Engine API to run queries in the beforeFactory to populate an array you can pass to a scripted data set. Or you can use the code in the open event of a scripted data set.</p>
<p> </p>
<p>The DevShare located @ <a data-ipb='nomediaparse' href='
http://developer.actuate.com/community/forum/index.php?/files/file/822-data-engine-api-to-check-data-set-values/'>http://developer.actuate.com/community/forum/index.php?/files/file/822-data-engine-api-to-check-data-set-values/</a>
; is a very good starting point.</p>
<p> </p>
<p>Please note that instead of this line:</p>
<pre class="_prettyXprint">
odaDataSet.setQueryText( dset.getQueryText() );</pre>
<p>You can update the query via the following, for example:</p>
<pre class="_prettyXprint">
odaDataSet.setQueryText( "SELECT CustomerID, myValue FROM CustomersTable WHERE StateName = 'CA'" );
</pre>
<p>Also, note for those OS and commercial BIRT readers, there is a difference in this line <span>queryDefinition</span><span>.</span><span>setAutoBinding</span><span>(</span><span>true</span><span>);</span></p>
<p> </p>
<p><span>OS BIRT:</span></p>
<pre class="_prettyXprint">
queryDefinition = new QueryDefinition();
queryDefinition.setDataSetName(dataSet.name);
queryDefinition.setAutoBinding(true);</pre>
<p>Commercial BIRT (comment out):</p>
<pre class="_prettyXprint">
queryDefinition = new QueryDefinition(true);
queryDefinition.setDataSetName(dataSet.name);
//queryDefinition.setAutoBinding(true);</pre>
<p>
</p>