Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us to spark ideas for how to put the latest capabilities into action. Register here!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

IF condition in an ODBC connect

Hi there

I develop the QV apply on my computer, and for this state, my appli feed itself with a database A.

When I've finished the apply, I transfert it on a windows server, and then, the apply should have to feed itself on a database B.

I think this is possible to test the server or whatever, with an IF condition, to execute one or the other connexion to the right database.

Like :

if ("I'm on my computer") {

     ODBC CONNECT TO [my_odbc_connexion_A];    

}

else {

     ODBC CONNECT TO [my_odbc_connexion_B];

}

But I don't know what I'am suppose to test on ? the IP ? the machine's name ?

Thanks for reading a french problem, excuse my president, and have a nice day

1 Solution

Accepted Solutions
rbecher
MVP
MVP

Hi,

I think ComputerName + OSUser is a good combination:

IF (ComputerName() = 'SRV00042' AND OSUser() = 'MI6\agent007') THEN

...

ELSE

...

END IF

- Ralf

Data & AI Engineer at Orionbelt.ai - a GenAI Semantic Layer Venture, Inventor of Astrato Engine

View solution in original post

4 Replies
rbecher
MVP
MVP

Hi,

I think ComputerName + OSUser is a good combination:

IF (ComputerName() = 'SRV00042' AND OSUser() = 'MI6\agent007') THEN

...

ELSE

...

END IF

- Ralf

Data & AI Engineer at Orionbelt.ai - a GenAI Semantic Layer Venture, Inventor of Astrato Engine
christophebrault
Specialist
Specialist

Hi,

I have this situation in an application where i have to know on wich server i am. I use a text file to store the name of the environment. I Load the file and then use the result in the if statement.

LOAD Environment

FROM MyFile.txt

if (Environment='A') {

     ODBC CONNECT TO [my_odbc_connexion_A];   

}

else {

     ODBC CONNECT TO [my_odbc_connexion_B];

}

Inscrivez vous à ma Newletter Qlik
DoNotMissQlik- Connect with me on Linkedin
Not applicable
Author

Thank you both of you for your proposal.

I'm gonna test this, and get back to say the result

Not applicable
Author

@christophebrault : I will use your method as I use a config.php file for websites, but not for now, I don't have much skill to use this in QV apply 

@Ralf Becher : so I decide to use your way, and to know the machine's name or the user, I've learn this (for other n00b like me)

Create a text-objet, and write this : =ComputerName() , the "=" symbol will print the value in the objet.

And the same for the OSUser() function.

Both of your way is good, so, again, thank you