Passing external parameter to QV script - qlikview

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.

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

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.

Related

Generated script of schema and table data not running in MS SERVER sqlcmd

I have a very large table script that is about ^ GB in size and cannot open in in Query Editor (obviously) due to memory/size.
I am trying to run it on the db server with the command propmt and using sqlcmd:
I am 100% sure the path and script name are correct (marked out for privacy reasons). I then used the following two scripts to get the DBServer\SQLInstance:
SELECT ##servername
SELECT ##servicename
What am I missing as it appears it has not done anything with the 21? _ prompt just sitting there. Do I need to do anything else?
I'm pretty sure the Windows command line pipeline is just choking on your previous command.
I think the best chance you have is doing this using PyPy:https://pypi.org/project/pymssql/, given the SQL instance has the memory to handle the data stream.

How to create Oracle 19C Database SQL Developer New Connection?

Well I am a college student and I have a database project to build on Oracle 19c (SQL Developer) just like a management system. When I click on new connection in SQl Developer , then enter database name (my project name) and enter user name as system and pswd. and is SID I write 'orclpdb' and when I connect it gives an error that database is not open. How can I start making tables and stuff and complete my project on oracle 19c sql developer. Please guide me.
Update: While creating new database connection in SQL Developer, In Service name if I write 'orcl' and test then the connection is successful but when I write 'orclpdb' it says 'database not open'
So it sound like the container database (orcl) is started but the pluggable database (orclpdb) is not. You need to start it.
In order to actually manage a database you are going to have to learn to work without SQL Developer, and use the command-line utility sqlplus.
From a command line:
C:> set ORACLE_SID=orcl
C:> sqlplus / as sysdba
SQL> alter pluggable database orclpdb open;
In the above, the sqlplus command is launching the command line utility 'sqlplus'. the '/' indicates to make a local connection to the database specified by the env variable ORACLE_SID, using OS authentication (os user is a member of the ORACLE_DBA group), and connect with 'sysdba' authority. On the next line the 'SQL>' is just indicating you are now at the sql prompt within sqlplus, you actually enter the 'alter' command, whose purpose should be self-evident.
The listener is a totally separate process. It is like a telephone switchboard. It 'listens' (hence, its name) for connection requests coming across the network, and set up the connection, then is out of the picture. You check its status at the command line:
C:> lsnrctl status
One last bit of useful (for us) information. What this the connection 'type' you've defined in SQL Dev? Is it 'basic' or 'tns'? Either way, what did you specify for the values? Please name the field(s) AND the value you supplied.

Neoload SQL ODBC database configuration

i have the task to connect NeoLoad to an ODBC oracle database for getting actual test data variables. My approach is to import a new variable type SQL and select Oracle as the driver and put in all the details i have.
When filling in the database configuration, i get the error
ORA-12505 TNS:listener does not currently know of SID given in connect descriptor
...which means, i miss the correct connection details. In this case, i only have a service name given and no SID.
connection_string_lt = "Driver={Microsoft ODBC for Oracle};CONNECTSTRING=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=a.b.c.com)(PORT = 1521))(CONNECT_DATA=(SERVICE_NAME=d.world)));uid=user;pwd=pwd"
When trying to get around this by selecting a custom database configuration, NeoLoad wants me to put a driver class and an URL.
However, i had difficulties to find the correct connection URL as it does not match with the connection data i have as well as the driver class, which i don't know where to get from (should i ask the database administrator ?).
Could somebody support me with how the input should look like for this ?
Thanks in advance.
Neoload has its own "SQL Connection" action which helps to connect with database and execute queries. To connect with Oracle it requires connection URL which can be in below format.
jdbc:oracle:thin:#//Hostname:1521/servicename
Username and Password of the Schema you need to access needs to be provided in required space.
Screenshot for connection

SQL Server - How to Copy a Stored Procedure to Another Database

I have a stored procedure with the exact same path on multiple servers (live, development and test) and I would like to modify/alter it simultaneously. I was thinking this would happen via altering one and then copying that and overwriting it over the other two servers.
Would this be easily achieved?
If you can connect to all the environments from a single SSMS (unlikely in many companies because of security), you can register all 3 SQL Server instances in a single group and execute the same script on all instances simultaneously
(refer to: https://msdn.microsoft.com/en-us/library/bb964743.aspx)
You can script out your stored procedure and use SQLCMD tool to execute it from file. Again, if you can connect to all instances from a single server, you can just duplicate the command in the script, but connect to multiple instances i.e. just use 3 SQLCMD lines
You can use any schema compare tool, Such as Red Gate SQL Compare
Also check alternative tools to Red Gate: Here
Also youo can check this opensource tool: Open DBdiff

Get Server and Database Name in SSIS Event Handler Task

I have a question regarding ssis packages. I have an ssis package with OnError, OnPreExecute and OnPostExecute. In these event handlers SQL task that perform different task and update different tables. My question is this: there are some system variables that I make use of like the SourceName and SourceDescriptin (which is the current sql task's name and description). I notice there isn't any variables for the connection (Server name, Database name) of the "Source" i.e step. Is there any way to get the database name and server name that Source/Step used? Any help will be much appreciated, thanking you in advance.
I dont think, we will have a system variable carrying the Server name and Db name. In an SSIS package, any number of connections can be created in the connection manager. So making them all available in a system variable will be not possible. I think such a thing need to be managed by developer itself. May be these steps will hep you.
1. Add a parameter (1 parameter per Server).
This parameter will be available through out the package.
2. When the package is running , if required give value to the parameter from SSIS catalog (through SSIS SPs)
For the server name, you can use the system variable called MachineName. It will give you the name of the machine the package is running on. As for the DB, you will have to capture it using a Execute SQL Task and store it within a variable of your choice.