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)
Most efficient way to access a dataset that returns a single value
Monma
I have a dataset that returns only one value (it could be more but for illustration purpose I am using one). I would like to access it (there are different ways that I can think of). But what interests me is the most efficient way to do so. For my interest this value will be used to check the status other processes and decide on actions depending on the status. But there are many usages for this.
The way I am thinking of doing this is build a dataset and bind a single cell table to it. Then use the setOnFetch script to store the value into a global variable like this:
repDesignHandle.findDataSet("MyDataSet").setOnFetch("reportContext.setPersistentGlobalVariable("StatusVar", this.row["status"])");
Find more posts tagged with
Comments
mwilliams
Hi Monma,
That is the best way I can think of for BIRT 2.2. In 2.5, there was the introduction of report variables. If/when you upgrade to 2.5+, you may be able to use a report varaible to store this value for easier access than a PGV. But, until then, that's probably the way to go.
Monma
What is the right syntax to use for the script to include in the setOnFitch method?. I am attaching an example for the purpose of illustration. It is based on ClassicModels. It seems that the value I am getting is always null.
mwilliams
Monma,<br />
<br />
Try this instead:<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
reportDesignHandle.findDataSet("OneValueDS").setOnFetch( "reportContext.setPersistentGlobalVariable("aValue", row["CUSTOMERNAME"])" );
var myTextData = elementFactory.newTextData( null );
myTextData.setValueExpr("reportContext.getPersistentGlobalVariable("aValue")");
reportDesignHandle.getBody().add(myTextData);
</pre>
<br />
This should show that it is, in fact, grabbing the value. Using a label doesn't work correctly because it doesn't use an expression. Let me know if you have questions.