Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » BIRT » dynamic data set from different table different feilds, according to parameter
dynamic data set from different table different feilds, according to parameter [message #684219] Wed, 15 June 2011 08:49 Go to next message
shengyongli is currently offline shengyongliFriend
Messages: 3
Registered: June 2011
Junior Member
Hi,
I just start BIRT so might get some wrong way. And this might sounnds a common question here.

I would like to fetch different feilds from different table according to one parameter's value.

Say if parameter value is "Apple", I would do query:

select taste from table_fruit;

if parameter value is "Rice", I would do query:

select protein from table_grain;


I knew I can do something in data set "beforeOpen" to replace string. But how can I control both the table name and the field name with one parameter? I am sure there are plenty of solution for this thing.

Thanks.


Re: dynamic data set from different table different feilds, according to parameter [message #684399 is a reply to message #684219] Wed, 15 June 2011 14:15 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason WeathersbyFriend
Messages: 9167
Registered: July 2009
Senior Member

Do table_fruit and table_grain have the same number of columns and
column types? In the before open you can check any report parameter and
set the query to whatever you want

if( params["food"].value == "Apple" ){
this.queryText = "select * from table_fruit";
}else{
this.queryText = "select * from table_grain";
}

The only issue is that both tables have to have the same column metadata
or you will get an error.

Jason

On 6/15/2011 4:49 AM, forums-noreply@eclipse.org wrote:
> Hi,
> I just start BIRT so might get some wrong way. And this might sounnds a
> common question here.
>
> I would like to fetch different feilds from different table according to
> one parameter's value.
> Say if parameter value is "Apple", I would do query:
>
> select taste from table_fruit;
>
> if parameter value is "Rice", I would do query:
>
> select protein from table_grain;
>
>
> I knew I can do something in data set "beforeOpen" to replace string.
> But how can I control both the table name and the field name with one
> parameter? I am sure there are plenty of solution for this thing.
> Thanks.
>
>
Re: dynamic data set from different table different feilds, according to parameter [message #684631 is a reply to message #684399] Thu, 16 June 2011 00:17 Go to previous messageGo to next message
shengyongli is currently offline shengyongliFriend
Messages: 3
Registered: June 2011
Junior Member
Thanks for the info. The issue came the two tables have different column numbers and name. According to param, the data set need to select different column from different table, but give same output. For example, choose "taste" (string) from table "fruit", and choose "protein" (string) from table "grain". Is it possible?

Alternatively, I can do it in another way.

Say I have a list item in report, how can I bind it to different data set according to param's value? Thanks.
Re: dynamic data set from different table different feilds, according to parameter [message #684708 is a reply to message #684631] Thu, 16 June 2011 04:57 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason WeathersbyFriend
Messages: 9167
Registered: July 2009
Senior Member

You could always create two datasets and add two tables to the report
and then use the parameter to drop one of them. for Example name the
two tables in their general properties to table1 and table2. Then in
the beforeFactory do this:

if( params["type"].value == fruit ){
reportContext.getDesignHandle().findElement("table1").drop();
}else{
reportContext.getDesignHandle().findElement("table2").drop();
}

You could always write de-api to change the column data in a script but
it will be more code than the above approach.

Jason

On 6/15/2011 8:17 PM, forums-noreply@eclipse.org wrote:
> Thanks for the info. The issue came the two tables have different column
> numbers and name. According to param, the data set need to select
> different column from different table, but give same output. For
> example, choose "taste" (string) from table "fruit", and choose
> "protein" (string) from table "grain". Is it possible?
> Alternatively, I can do it in another way.
>
> Say I have a list item in report, how can I bind it to different data
> set according to param's value? Thanks.
Re: dynamic data set from different table different feilds, according to parameter [message #685216 is a reply to message #684708] Fri, 17 June 2011 03:39 Go to previous message
shengyongli is currently offline shengyongliFriend
Messages: 3
Registered: June 2011
Junior Member
Thank you for that, Jason.
Previous Topic:How to retrieve ResultSet metadata in script
Next Topic:Drill-Through
Goto Forum:
  


Current Time: Wed Nov 26 14:22:33 GMT 2014

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

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