Storing query result in report parameter
#1
Posted 30 June 2009 - 11:57 AM
I need to get a value using SQL and use this value later in the report as parameter for other queries and various conditions.
For example, I need to call this query somewhere in the early stages of report (initialize, before factory, etc):
select userid from users where ....
and then store this "userid" as parameter for later use.
Any advice?
I am using 2.3.2
Thank you
#2
Posted 30 June 2009 - 12:47 PM
reportContext.setPersistentGlobalVariable(name, value);
You can also directly set the value of the report parameter in a script. this will allow you to bind the value into a query using the data set editor (take care when you do this assignment as your Data Set may have already been built:
params["param_name"].value = "something";
A last option would be to modify your query in the Data Set's initialize script. There you can check your persistent global variable and use the value to further tweak your query text.
this.queryText = this.queryText + " WHERE userid = " + reportContext.getPersistentGlobalVariable("userID");
Any of those approaches should work fine.
Good Luck!!
#3
Posted 01 July 2009 - 07:49 AM
How can I ensure that the SQL that returns my userIdValue is executed before any other queries that are used in the report?
Say, I want to run the query first (getting userIdValue), then then do as you advised.
reportContext.setPersistentGlobalVariable(name, userIdValue);
Is there any call to execute the SQL from javascrip?
Thanks!
#4
Posted 01 July 2009 - 10:02 AM
There are examples for creating these handlers on the DevShare.
Using Java to Write a BIRT Event Handler - Tips & Tricks - BIRT Exchange
Good Luck!



MultiQuote
