Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
beforeopen() script not working as intended
RokieRiver
Hi All! I am new to BIRT and need help in following:
where clause condition mentioned in the beforeOpen() script not having any effect on the result set displayed on the preview.
I appreciate your time and advise..thanks in advance!
Find more posts tagged with
Comments
mwilliams
What is your BIRT version? And what is the code you're putting in the beforeOpen? Also, what is your query? Do you get any errors?
thuston
You have to ultimately alter this.queryText.
What are you currently doing?
RokieRiver
<blockquote class='ipsBlockquote' data-author="'mwilliams'" data-cid="81290" data-time="1312836173" data-date="08 August 2011 - 01:42 PM"><p>
What is your BIRT version? And what is the code you're putting in the beforeOpen? Also, what is your query? Do you get any errors?<br /></p></blockquote>
<br />
<br />
Hi,<br />
<br />
I am using eclipse version 3.4.1.and <br />
BIRT viewer version :org.eclipse.birt.report.viewer_2.3.1.v20080908.<br />
I get no errors when I preview the report.<br />
<br />
I put following in beforeopen()<br />
<br />
<em class='bbc'>if (params["employee"].value != null) <br />
{<br />
this.queryText += " AND (Lower(T.empName) LIKE '" + params["employee"].value.toLowerCase() + "%')"; <br />
}</em><br />
<br />
main query on dataaset = <em class='bbc'>select * from table T where T.empID = 2</em>
RokieRiver
<blockquote class='ipsBlockquote' data-author="'thuston'" data-cid="81291" data-time="1312836196" data-date="08 August 2011 - 01:43 PM"><p>
You have to ultimately alter this.queryText.<br />
What are you currently doing?<br /></p></blockquote>
<br />
<br />
I am trying to fetch all records from a employee table and based on the filter options that user selects (report parameters), I want to add additional where clauses to the orginal dataset query.<br />
This will display only those rows that user is interested in.
mwilliams
Put this in your initialize method:
QT = "";
Put this in your beforeOpen method after you add to your query text:
QT = this.queryText;
Then, put this in a dynamic textbox in your report after a table that is bound to your dataSet:
QT;
This should show you what query text is going to your database. This might help show you what's not coming out right.
RokieRiver
<blockquote class='ipsBlockquote' data-author="'mwilliams'" data-cid="81295" data-time="1312837320" data-date="08 August 2011 - 02:02 PM"><p>
Put this in your initialize method:<br />
<br />
QT = "";<br />
<br />
Put this in your beforeOpen method after you add to your query text:<br />
<br />
QT = this.queryText;<br />
<br />
Then, put this in a dynamic textbox in your report after a table that is bound to your dataSet:<br />
<br />
QT;<br />
<br />
This should show you what query text is going to your database. This might help show you what's not coming out right.<br /></p></blockquote>
<br />
<br />
<br />
I made few syntax changes refereing to what was dsiplayed in 'QT' ..but now I get below error:<br />
<br />
<em class='bbc'>java.lang.ClassCastException: java.lang.OutOfMemoryError cannot be cast to java.lang.Exception</em>
mwilliams
How much data are you trying to pull? If you make the query the same only use static values rather than parametrized ones, do you get data returned?
RokieRiver
<blockquote class='ipsBlockquote' data-author="'mwilliams'" data-cid="81298" data-time="1312838659" data-date="08 August 2011 - 02:24 PM"><p>
How much data are you trying to pull? If you make the query the same only use static values rather than parametrized ones, do you get data returned?<br /></p></blockquote>
<br />
No parameters are created on the dataset...all are static values.The number of rows that should be pulled is below 50 rows from the table. Not much data on the table.
mwilliams
You use a report parameter in your query. I just meant replacing that with a static value that would return some rows, preferably a small amount of them.
Could you attempt to get this same error to appear with the same setup using the sample database? I don't know that you'll get it to happen, but I'd like to have a report to test on if possible.
thuston
<blockquote class='ipsBlockquote' data-author="'RokieRiver'" data-cid="81292" data-time="1312836667" data-date="08 August 2011 - 01:51 PM"><p>
<em class='bbc'>if (params["employee"].value != null) <br />
{<br />
this.queryText += " AND (Lower(T.empName) LIKE '" + params["employee"].value.toLowerCase() + "%')"; <br />
}</em><br />
<br />
main query on dataaset = <em class='bbc'>select * from table T where T.empID = 2</em><br /></p></blockquote>
<br />
Just in case, try the long way and see if it actually updates your SQL.<br />
queryText = queryText + " AND (Lower(T.empName) LIKE '" + params["employee"].value.toLowerCase() + "%')";
rihanna
Hi!
I had exact the same problem, I had appending to query where clause in beforeOpen script with report parameters and it wouldn't give any impact to the dataset results. I would get all the existing records in the database. It was very frustrating because it works with other reports fine, so I just re-created the report again from scratch and it worked.
RokieRiver
<blockquote class='ipsBlockquote' data-author="'mwilliams'" data-cid="81302" data-time="1312839747" data-date="08 August 2011 - 02:42 PM"><p>
You use a report parameter in your query. I just meant replacing that with a static value that would return some rows, preferably a small amount of them.<br />
<br />
Could you attempt to get this same error to appear with the same setup using the sample database? I don't know that you'll get it to happen, but I'd like to have a report to test on if possible.<br /></p></blockquote>
<br />
I am trying to start the report from scratch ..but surprisingly...if I create any report parameters ..it just does not fetch any thing from database. If I give static values in the query then I can preview some rows. Why does this happen?
RokieRiver
<blockquote class='ipsBlockquote' data-author="'rihanna'" data-cid="81305" data-time="1312843985" data-date="08 August 2011 - 03:53 PM"><p>
Hi! <br />
I had exact the same problem, I had appending to query where clause in beforeOpen script with report parameters and it wouldn't give any impact to the dataset results. I would get all the existing records in the database. It was very frustrating because it works with other reports fine, so I just re-created the report again from scratch and it worked.<br /></p></blockquote>
<br />
I tried starting from scratch ..but ran into new issue. None of report parameters seem to work. Only static values in query is working... :-(
mwilliams
Can you recreate the issue with the sample database at all?
RokieRiver
<blockquote class='ipsBlockquote' data-author="'mwilliams'" data-cid="81355" data-time="1312930974" data-date="09 August 2011 - 04:02 PM"><p>
Can you recreate the issue with the sample database at all?<br /></p></blockquote>
<br />
Unfortunately no...I tried several times..it just hapening on the report that I am working on. anyways I have started from scratch..lets see If I hit it again...<br />
The parameter issue just got resolved when I deleted those and recreated it again (did this a few times)<br />
<br />
<em class='bbc'>Parameter issue = if I have some dynamic values coming in from report parameters..the preview query results was returning 0 rows</em>
RokieRiver
Hi All,
Wanted to share about my resolution...well..not sure if it can be called a resolution.
1>I closed the eclipse and restarted it.
2>Deleted and re-added the report and dataset parameters several times , untill it stopped erroring out.
3>Added script line by line and checked the preview everytime I add a new line of code.
4>I used to close the report design file and reopen it several times.
After starting from scratch, above steps have helped me do the designing without errors.I hope this helps others.
Thanks to all who took time to reply to my queries.
mwilliams
Sorry you had such a difficult time with this. I have never heard of this kind of difficulty with parameters. Maybe upgrading BIRT versions would solve the issue.
thuston
To avoid random errors, I always modify my C:\Program Files (x86)\Actuate11\BRDPro\eclipse\eclipse.ini and add -clean as the first line.<br />
This makes the next startup last a few minutes and subsequent startups about 30 seconds, but I almost never see errors that are resolved by simply duplicating effort.<br />
<br />
Here is the note from eclipse docs:<br />
<blockquote class='ipsBlockquote' ><p>Note that -clean flushes the registry caches (amung other information) and forces the plug-in manifests to be parsed in order to regenerate the registry. This is not optimal for everyone all the time because (depending on the size of your development environment) it may take up to a couple of minutes</p></blockquote>
gunasekar
-