Home
Analytics
Execute query without using it in the report
ShlomiW
<p>Hi all,</p><p> </p><p>I would like to know if there is any way to make Birt Execute a query <strong>but </strong>without adding an hidden table (or any other element) in the report.</p><p> </p><p>For now I know that a query will be executed only if it present in the report, but I need to use the data that the query returns but I don't want to add unnecessary elements to my report.</p><p> </p><p>Please help me</p><p>Have a good day</p><p>Shlomi</p>
Find more posts tagged with
Comments
mwilliams
<p>Take a look at this devshare post:</p><p> </p><p><a data-ipb='nomediaparse' href='
http://www.birt-exchange.org/devshare/_/designing-birt-reports/1542-data-engine-api-to-check-data-set-values'>http://www.birt-exchange.org/devshare/_/designing-birt-reports/1542-data-engine-api-to-check-data-set-values</a></p>
;
ShlomiW
<p>Thank you.</p><p> </p><p>I have seen this post before writing mine, but it looked a little bit to much</p><pre class="_prettyXprint _lang-">var myconfig = reportContext.getReportRunnable().getReportEngine().getConfig();var de = DataEngine.newDataEngine( myconfig, null );var dsrc = reportContext.getDesignHandle().findDataSource("Data Source");var dset = reportContext.getDesignHandle().findDataSet("Data Set2");var odaDataSource = new OdaDataSourceDesign( "Test Data Source" );odaDataSource.setExtensionID( "org.eclipse.birt.report.data.oda.jdbc" );odaDataSource.addPublicProperty( "odaURL", dsrc.getProperty("odaURL").toString() );odaDataSource.addPublicProperty( "odaDriverClass", dsrc.getProperty("odaDriverClass").toString());odaDataSource.addPublicProperty( "odaUser", dsrc.getProperty("odaUser").toString() );odaDataSource.addPublicProperty( "odaPassword", "" ); var odaDataSet = new OdaDataSetDesign( "Test Data Set" );odaDataSet.setDataSource( odaDataSource.getName( ) );odaDataSet.setExtensionID( "org.eclipse.birt.report.data.oda.jdbc.JdbcSelectDataSet" );odaDataSet.setQueryText( dset.getQueryText() ); inputParamDefn = new ParameterDefinition( "param_1",DataType.INTEGER_TYPE );inputParamDefn.setInputMode( true );inputParamDefn.setPosition( 1 );inputParamDefn.setDefaultInputValue( 10102 );odaDataSet.addParameter( inputParamDefn );if( params["order"].value != null ){paramBinding = new InputParameterBinding( "param_1",new ScriptExpression( params["order"] ) );}else{paramBinding = new InputParameterBinding( "param_1",new ScriptExpression( 111111 ) );}de.defineDataSource( odaDataSource );de.defineDataSet( odaDataSet ); queryDefinition = new QueryDefinition( );queryDefinition.setDataSetName( odaDataSet.getName() );queryDefinition.addInputParamBinding( paramBinding );queryDefinition.setAutoBinding(true);</pre><p>it look's like he creating a new data-set based on a data-set and a data-source that we already has.</p><p> </p><p>Beascally, my question is: can't I just use a code like</p><pre class="_prettyXprint">var result= reportContext.getDesignHandle().findDataSet("my Data Set").execute();</pre><p>Waiting to hear from you again</p><p>Shlomi</p>
mwilliams
<p>Yes, this is essentially creating a new dataSource and dataset to execute your query. The only other way a query is executed is if it's bound to an element in the report, which you said you were not wanting to do. The simplest way to disguise the use of an "extra" element would be to use a text box for your report title or something and bind it to the dataset you want to run. This way you wouldn't be using an extra element, but would still get the dataset to run.</p>
ShlomiW
<p>sorry for the late response.</p><p> </p><p>we move back to using hidden tables in the top of the report, and using those tables to read the data from the dataset.</p><p> </p><p>Thank you for your help</p>