Qlikview Scripting Tips: Connection Strings and Variables 2

QVDynamicConnectionStringWhen building and testing a QV application, you will typically use a production database (or live EDW) or a test database. It’s helpful to have a variable switch in the script to allow you to easily switch back and forth between the test and prod server. QQQ blog has a great explanation of how to use this variable switch.

It’s relatively easy to create a simple switch with which you can switch between development and production connections. Let’s show an example:

SET vProduction= 0;

IF vProduction = 1 THEN
···ODBC CONNECT TO MyOracleDBProd (XUserID is *****, Xpassword is ****)
SET vDBName = ‘MyOracleDBProd‘;
ELSE
···ODBC CONNECT TO MyOracleDBDev (XUserID is *****, Xpassword is ****)
SET vDBName = ‘MyOracleDBDev‘;
END IF

So that’s the switch, now in your load statements use the variable we just created like below:

SQL SELECT *
FROM $(vDBName).MySchema.MyTable;

 

Matt Floyd‘s insight:

It’s good practice to include this switch if you are in a multi-db environment. Setup is quick and usage is even quicker. Update: Qlik Share has posted a great video on using an external script for a dynamic connection string.

  • sajad

    thanks for sharing, this works for me

  • srini

    this is good info..how can I check for failure ODBC connection incase of multi server..say I have primary and secondary servers, if primary fails it should try connecting to secondary

Follow

Get every new post delivered to your Inbox

Join other followers: