Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » BIRT » Set a variable using the output of a SQL query
Set a variable using the output of a SQL query [message #850798] Fri, 20 April 2012 10:41 Go to next message
ing omini is currently offline ing ominiFriend
Messages: 26
Registered: March 2012
Junior Member
Hi people,
a question regarding variables...

Up to now I always used variables defined in report context to filter dataset results (for example by using those variables inside parameters and filters options of a dataset).

Now I want to understand if it's possible to go in the other way.
Is it possible to set the value of a variable using the dataset content?

For example, if my dataset is:

select first_day, last_day
from external_config_table

can I assign the output query values to report variables??

pseudocode example:
my_variable_firstday = row[1].first_day ;
my_variable_firstday = row[1].last_day ;

Thanks in advance...
Re: Set a variable using the output of a SQL query [message #851110 is a reply to message #850798] Fri, 20 April 2012 16:54 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason WeathersbyFriend
Messages: 9167
Registered: July 2009
Senior Member

If you create a dataset and then use the dataset in a table in the
report (Even if the table is hidden) you can get the row values and
store them in a variable. For example, on a table's detail row you
could add an oncreate script like:

myvar = this.getRowData().getColumnValue("QTY");

Look at the bindings tab in the property editor to get the column names.
Once you have the var you can also store it globally lie:

reportContext.setGlobalVariable("mygvar" , myvar); or like
reportContext.setPersistentGlobalVariable("mygvar" , myvar)

You can then use this variable downstream by calling

reportContext.getGlobalVariable("mygvar"); or
reportContext.getPersistentGlobalVariable("mygvar");

Jason


On 4/20/2012 6:41 AM, ing omini wrote:
> Hi people,
> a question regarding variables...
>
> Up to now I always used variables defined in report context to filter
> dataset results (for example by using those variables inside parameters
> and filters options of a dataset).
>
> Now I want to understand if it's possible to go in the other way.
> Is it possible to set the value of a variable using the dataset content?
> For example, if my dataset is:
>
> select first_day, last_day from external_config_table
>
> can I assign the output query values to report variables??
>
> pseudocode example:
> my_variable_firstday = row[1].first_day ;
> my_variable_firstday = row[1].last_day ;
>
> Thanks in advance...
>
Re: Set a variable using the output of a SQL query [message #853959 is a reply to message #851110] Mon, 23 April 2012 14:08 Go to previous message
ing omini is currently offline ing ominiFriend
Messages: 26
Registered: March 2012
Junior Member
Ok perfect!
Previous Topic:Using BIRT with jsf4birt.jar on tomcat server/websphere
Next Topic:Dropped elements still being rendered
Goto Forum:
  


Current Time: Fri Apr 19 22:40:30 GMT 2024

Powered by FUDForum. Page generated in 0.02869 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top