Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » BIRT » change query depending on locale [solved]
change query depending on locale [solved] [message #1223515] Mon, 23 December 2013 16:21 Go to next message
José Litux is currently offline José LituxFriend
Messages: 52
Registered: March 2013
Member
Hi


I'm trying to modify the SQL query for a Chart depending on the locale. What I get so far :

beforeFactory

var mylocale=reportContext.getLocale().toString().substr(1,2)


But I'm stuck on retrieving the parameter and inserting on the query. Something like this:

Select * from table where country=' + param["mylocale"] + '


Any help would be much appreciated

[Updated on: Fri, 07 February 2014 17:53]

Report message to a moderator

Re: change query depending on locale [message #1240442 is a reply to message #1223515] Thu, 06 February 2014 13:19 Go to previous messageGo to next message
José Litux is currently offline José LituxFriend
Messages: 52
Registered: March 2013
Member
any hint?
Re: change query depending on locale [message #1240476 is a reply to message #1240442] Thu, 06 February 2014 14:53 Go to previous messageGo to next message
donino donino is currently offline donino doninoFriend
Messages: 162
Registered: July 2011
Senior Member
I don't think it is necessary to use a report parameter such "mylocale" here. You could try this:

In the query of your dataset, use a question mark like this:
Select * from table where country=?


Then in parameters section of the dataset, edit the parameter and just fill the "Default value" property with the expression you mentionned:
reportContext.getLocale().toString().substr(1,2)


I hope this helps!
Re: change query depending on locale [message #1240557] Thu, 06 February 2014 19:07 Go to previous messageGo to next message
José Litux is currently offline José LituxFriend
Messages: 52
Registered: March 2013
Member
Hi donino

i'm afraid I gave a wrong example.
The real query is more a thing like this:

If locale is French, select French_name, french_description from product

If locale is English, select englîsh_name, english_description from product

I can get the locale but I'm stuck on getting the proper SQL to work in the dataset


Thanks in advance

[Updated on: Thu, 06 February 2014 20:58]

Report message to a moderator

Re: change query depending on locale [message #1240983 is a reply to message #1240557] Fri, 07 February 2014 09:50 Go to previous messageGo to next message
donino donino is currently offline donino doninoFriend
Messages: 162
Registered: July 2011
Senior Member
In this case you need to change your query depending on the value of the locale. In the beforeOpen script of the dataset. You probably need to use aliases so that BIRT can still match columns dataset with the result of the query. It would be something like:

var mylocale=reportContext.getLocale().toString().substr(1,2);
if (mylocale=="fr"){
    this.queryText="select French_name as name, french_description as description from product";
}else if(mylocale=="en"){
    this.queryText="select englîsh_name as name, english_description as description from product";
}


Let me know if it helps

[Updated on: Fri, 07 February 2014 09:54]

Report message to a moderator

Re: change query depending on locale [message #1241250 is a reply to message #1240983] Fri, 07 February 2014 17:52 Go to previous messageGo to next message
José Litux is currently offline José LituxFriend
Messages: 52
Registered: March 2013
Member
So easy I feel stupid right now Sad

worked perfectly.

Thanks domino

[Updated on: Fri, 07 February 2014 17:53]

Report message to a moderator

Re: change query depending on locale [message #1371736 is a reply to message #1240476] Wed, 21 May 2014 14:16 Go to previous message
Kristopher Clark is currently offline Kristopher ClarkFriend
Messages: 130
Registered: January 2013
Senior Member
donino donino wrote:
> I don't think it is necessary to use a report parameter such "mylocale"
> here. You could try this:
>
> In the query of your dataset, use a question mark like this:
> Select * from table where country=?
>
> Then in parameters section of the dataset, edit the parameter and just
> fill the "Default value" property with the expression you mentionned:
> reportContext.getLocale().toString().substr(1,2)
>
> I hope this helps!

Jose,
You could use something like this in the beforeOpen() of the data source

var locale = reportContext.getLocale().toString()
locale = locale.substr(3,4);

this.queryText = "select * from customers where country = '" + locale + "'";
Previous Topic:I need some help with few things - drill, hyperlinks etc.
Next Topic:BIRT Report ppt is not opening in MS Office 2013
Goto Forum:
  


Current Time: Sun Nov 23 12:28:16 GMT 2014

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

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