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)
Toubles in changing the query within te beforeOpen method.
Howl
Hi to all,
I'm having some toubles in implementing an alternative query that has to be executed during the beforeOpen under certain conditions.
I tried a quite simple query to test the beforeOpen, but it seems like I'm not able to read the report parameter value.
Here's what I'm doing:
I set a report parameter named fkId that has type string and default value 0.
In my dataset I'm executing the following query:
SELECT CODICE_RNI FROM RNI_TIPOLOGIA_MATERIALE WHERE TIPOLOGIA = ?
Obviously linking a dataset parameter to the report parameter. If I insert the right string the query gets correctly executed.
Now comes the tricky (for me) part!
In the beforeOpen method of the dataset I wrote the following code:
if(reportContext.getParameterValue("fkId") == "Materiale")
{
this.queryText = "SELECT CODICE_RNI FROM RNI_TIPOLOGIA_MATERIALE";
}
When it comes toexecute the report I get the following exception:
Cannot set the string value (0) to parameter 1. Cannot set preparedStatement parameter string value. SQL error#1: column index not valid.
What am I not considering?
Thanks for your help.
Find more posts tagged with
Comments
Mega
You have specified a parameter which is not being used, BIRT can't find where to put it.<br />
<br />
<br />
A tricky an ugly solution (I'm sure there is better one...) would be this:<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
if(reportContext.getParameterValue("fkId") == "Materiale")
{
this.queryText = "SELECT CODICE_RNI FROM RNI_TIPOLOGIA_MATERIALE AND ? = 'Materiale' ";
}
</pre>
<br />
Hope that helps for the moment