Home
Analytics
Dataset afterOpen() Row Count
joeguzman1
<strong class='bbc'>Eclipse Indigo 3.7.1.r37x_v20110810-0800-7b7qFVtFEx2XnmZ4jlM5mjM </strong><br />
<strong class='bbc'>Build id:</strong> M20110909-1335<br />
<br />
<strong class='bbc'>BIRT 3.7.1.v20110905-4607w31221A16</strong><br />
<strong class='bbc'>BIRT Build id:</strong> v20110913-1734<br />
<br />
<strong class='bbc'>BIRT JDBC Data Source</strong><br />
<strong class='bbc'>File:</strong> jtds-1.2.5.jar<br />
<strong class='bbc'>Driver Class:</strong> net.sourceforge.jtds.jdbc.Driver (v1.2)<br />
<br />
<br />
<strong class='bbc'>Is there a way (using scripting example: <em class='bbc'>dataset afterOpen()</em>):</strong><br />
1. Determine dataset row count<br />
2. If row count exceeds a predetermined value:<br />
<br />
Pop-up message: <span class='bbc_underline'>Please Reduce The Selection Criteria</span><br />
Abort report or allow user to select new criteria<br />
<br />
Please note setting the data set row limit is not desirable.<br />
<br />
Thank you for the great support you have provided in the past.<br />
<strong class='bbc'>BIRT rocks!</strong>
Find more posts tagged with
Comments
mwilliams
One option could be that you could create a connection to your database in your beforeFactory script and check the return of your query with the selected parameters. If they exceed your limit, you could drop all the elements from your report except for a text box that tells them their selections returned too many values and to select new criteria. Then you could provide a button to "try again" that would re-run the report.
joeguzman1
<strong class='bbc'>Can you please provide an example.</strong> <br />
I tried using the following function in <strong class='bbc'>beforeFactory</strong>() but got a connection error.<br />
<br />
<strong class='bbc'>beforeFactory</strong>()<br />
GetRowCount("Report_dsJob_History_by_Date");<br />
<br />
<strong class='bbc'>function GetRowCount(DataSet)</strong><br />
{<br />
importPackage(Packages.org.eclipse.birt.report.model.api );<br />
importPackage(Packages.java.lang);<br />
importPackage(Packages.java.util);<br />
importPackage(Packages.org.eclipse.birt.data.engine.api);<br />
importPackage(Packages.org.eclipse.birt.report.model.api);<br />
importPackage(Packages.org.eclipse.birt.data.engine.api.querydefn);<br />
importPackage(Packages.org.eclipse.birt.data.engine.core);<br />
<br />
var myconfig = reportContext.getReportRunnable().getReportEngine().getConfig();<br />
var de = DataEngine.newDataEngine( myconfig, null );<br />
<br />
var dsrc = reportContext.getDesignHandle().findDataSource("opconxps");<br />
var dset = reportContext.getDesignHandle().findDataSet(DataSet);<br />
<br />
var odaDataSource = new OdaDataSourceDesign( "Test Data Source" );<br />
odaDataSource.setExtensionID( "org.eclipse.birt.report.data.oda.jdbc" );<br />
odaDataSource.addPublicProperty( "odaURL", dsrc.getProperty("odaURL").toString() );<br />
odaDataSource.addPublicProperty( "odaDriverClass", dsrc.getProperty("odaDriverClass").toString());<br />
odaDataSource.addPublicProperty( "odaUser", dsrc.getProperty("odaUser").toString() );<br />
odaDataSource.addPublicProperty( "odaPassword", "" ); <br />
<br />
var odaDataSet = new OdaDataSetDesign( "Test Data Set" );<br />
odaDataSet.setDataSource( odaDataSource.getName( ) );<br />
odaDataSet.setExtensionID( "org.eclipse.birt.report.data.oda.jdbc.JdbcSelectDataSet" );<br />
odaDataSet.setQueryText( dset.getQueryText() ); <br />
<br />
de.defineDataSource( odaDataSource );<br />
de.defineDataSet( odaDataSet );<br />
<br />
queryDefinition = new QueryDefinition( );<br />
queryDefinition.setDataSetName( odaDataSet.getName() );<br />
queryDefinition.setAutoBinding(true);<br />
<br />
<br />
var pq = de.prepare( queryDefinition );<br />
<br />
var qr = pq.execute( null );<br />
<br />
rowcount=0; <br />
var ri = qr.getResultIterator( ); <br />
while ( ri.next( ) )<br />
{ <br />
rowcount++<br />
}<br />
<br />
ri.close( );<br />
qr.close( );<br />
de.shutdown( );<br />
<br />
return rowcount;<br />
}
mwilliams
Take a look at this devShare post. Maybe it'll help.
http://www.birt-exchange.org/org/devshare/designing-birt-reports/1428-birt-jdbc-oda-with-jdbc-resultset-override/
adagreen
<blockquote class="ipsBlockquote" data-author="mwilliams" data-cid="95712" data-time="1328897646">
<div>
<p>Take a look at this devShare post. Maybe it'll help. <a data-ipb='nomediaparse' href='
http://www.birt-exchange.org/org/devshare/designing-birt-reports/1428-birt-jdbc-oda-with-jdbc-resultset-override/'>http://www.birt-exchange.org/org/devshare/designing-birt-reports/1428-birt-jdbc-oda-with-jdbc-resultset-override/</a></p>
;
</div>
</blockquote>
<p>Thanks a ton!!</p>
<p>Very helpful. :P</p>
mehdiesteghamat
<p>hi,</p>
<p> </p>
<p>I am trying to do that using initialize, and onFetch method as below but not working. Please let me know what is wrong.</p>
<p> </p>
<p>thank you in advance,</p>
<p> </p>
<p> </p>
<p>-- initialize</p>
<p>reportContext.setPersistentGlobalVariable("myrowcount","0");</p>
<p> </p>
<p>-- onFetch</p>
<div>a = parseInt(reportContext.getPersistentGlobalVariable("myrowcount"))+1;</div>
<div>a++;</div>
<div>reportContext.setPersistentGlobalVariable("myrowcount",a.toString());</div>
<p> </p>
<p> </p>
<p>-- onRender</p>
<p>this.text="Rowcount = " + reportContext.getPersistentGlobalVariable("myrowcount");</p>