2

I am a newbie to QlikView and looking for some guidance on how to pass external parameter to qv script i.e qvw file.

Below is the scenario on which I am working:

We are creating a report for which the source is database and we will be using automation tools to trigger the script from Linux servers. Now after doing a bit of research I found two ways to connect to the database from QV script.

1) Use the connection string in script to connect the db but in our case the passwords are changed after every 3 months. So it cancels out this option.

2) Other option is to create a text file on qv server from linux job which will hold the connection string and include that text file into the script. This option is ruled out for my case as our qv server is shared by other teams and it is not secure to have password hard coded in a file on common server.

Now I am thinking to pass connection string or user name and password as a parameter to the script from the automation tool.

Is it possible to pass external parameters to qv script from linux server? And if yes, how to do it?

Something like below:

ODBC CONNECT TO server (XUserId is $(vuser), XPassword is $(vpwd));
SQL SELECT * FROM db.table;

$(vuser) and $(vpwd) are variables.

Thanks in advance for your time and please let me know if you need more clarification on this.

Explorer
  • 1,491
  • 4
  • 26
  • 67

2 Answers2

3

The chapter 7.1 Command Line Syntax of Qlikview Reference Manual (which i strongly recommend getting and using heavily) says:

/v

If this switch is immediately followed by a variable name and an assignment, the variable will obtain the assigned value before the script execution starts.

What manual will not tell you, that the variable has to exist in the script, i.e. you add variable via Settings->Variable overview Ctrl-Alt-V and then you can pass it via:

qv /r /vvuser=user1 file.qvw
jezrael
  • 822,522
  • 95
  • 1,334
  • 1,252
chukko
  • 430
  • 4
  • 10
0

I use a different solution. In every qlikview file I add the line

$(must_include=.\etc\DBConnect.txt);

The connection is then defined in the text file DBConnect.txt which may look like this:

ODBC CONNECT TO [conn] (XUserId is cRQCaaaaaaaaaaabbbbbbbROaA, XPassword is YaaaaaaBBBBBBBBZ);

This way all users in the company may use the same qlikview files and refresh it by using their own credentials. However it is neccessary that all have the same name for the ODBC connection to the server.

petezurich
  • 9,280
  • 9
  • 43
  • 57