Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi guys,
I don't know if my question has already been answered in another post but I couldn't find anything on the topic.
Here is the thing:
I know we can use a variable as parameter in a WHERE condition in a SQL SELECT e.g:
SQL SELECT * FROM DB.Table WHERE Date=$(MyDate) -- or something approaching.
Now my issue is that I have to use different databases when moving from DEV to PREPROD and PROD.
So taking the same example, in DEV the name of the database will be DB when in PREPROD it will be PPDB (don't ask why the back end team has created different database names in different environments).
What I am trying to do is to set dynamically the name of the database so that I don't have to change manually the name in all my applications e.g:
SET DBname = If(PREPROD, 'PP','')
SQL SELECT * FROM $(DBname)DB.Table
Do you know if this is possible to use a variable in the SQL Select itself, and if yes how I could to that.
Thanks in advance for your help.
Jon
Hi
Change the SET to LET DBname = If(PREPROD, 'PP','');
Then it should work.
HTH
Jonathan
Not sure about dynamic selection of DB in SQL Select. But possible to change the odbc dynamically. Check out here
Dynamic Connection String in QlikView - QlikView Blog, QlikView Videos and Tips at QlikShare
Hi
Change the SET to LET DBname = If(PREPROD, 'PP','');
Then it should work.
HTH
Jonathan
Hi,
Configure the database dynamically in your connection string so that you don't need to do this in all select queries. Please check below
LET DBname = If(PREPROD, 'PP','')
ODBC CONNECT TO [orafin;DBQ=$(DBname)] (XUserId is saetst, XPassword is stedfdf);
Hope this helps you.
Regards,
Jagan.
That was a pretty stupid question in fact and really easy to fix.....
Thanks guys useful answers.
Cheers
Jon