|
|||
|
Hi,
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 |
|
|||
|
Once you have your UserID, you can set a persistent global variable in the scripting layer. This variable will be available within any other event handler you may need:
Code:
reportContext.setPersistentGlobalVariable(name, value); Code:
params["param_name"].value = "something"; Code:
this.queryText = this.queryText + " WHERE userid = " + reportContext.getPersistentGlobalVariable("userID");
Good Luck!! |
|
|||
|
Thanks a lot!
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. Code:
reportContext.setPersistentGlobalVariable(name, userIdValue); Thanks! |
|
|||
|
You should probably create a Java Event Handler and invoke that via the report's initialize event. Executing SQL from a full-blown Java object will perform much better.
There are examples for creating these handlers on the DevShare. Using Java to Write a BIRT Event Handler - Tips & Tricks - BIRT Exchange Good Luck! |
![]() |
| Thread Tools | |
| Display Modes | |
|
|