Qlik Community

QlikView App Dev

Discussion Board for collaboration related to QlikView App Development.

Announcements
IMPORTANT security patches for GeoAnalytics Server available to download: READ DETAILS
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Switching SQL Connection String with external file

Hi all,

I try to setup my QlikView script to switch between two OLEDB Connection Strings via a external file.

Storing my Connection Strings in two different qvs files (CONNECTION_SQL_TEST.qvs and CONNECTION_SQL_PROD.qvs)

Loading the file text file that contains the Instance Name (TEST or PROD) and write a variable called vSQL_INSTANCE. In this variable it will be simply stored 'TEST' or 'PROD'

Tried to create a condition like this:

if($(vSQL_INSTANCE)='TEST'
,
$(Include=$(path_toggel)CONNECTION_SQL_TEST.qvs);
,
$(Include=$(path_toggel)CONNECTION_SQL_PROD.qvs);
)

Result -> Syntax Error.


Could anymody help me with that?

Is it actualy possible to use a if condition in combination with Connection Strings?

Thank you for your efforts.

Kind Regrads

Philipp

1 Solution

Accepted Solutions
jonathandienst
Partner
Partner

Dont try to do it in an expression. Use this:

If vSQL_INSTANCE = 'TEST' Then

  $(Include=$(path_toggel)CONNECTION_SQL_TEST.qvs);

Else

  $(Include=$(path_toggel)CONNECTION_SQL_PROD.qvs);

End If

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein

View solution in original post

6 Replies
Not applicable
Author

if($(vSQL_INSTANCE)='TEST'
,
$(Include=$(path_toggel)CONNECTION_SQL_TEST.qvs)
,
$(Include=$(path_toggel)CONNECTION_SQL_PROD.qvs)
);

Not applicable
Author

Hi Rodrigo,

thank you for answering, but this is also not working "Script Error - Unknown statement" ...

I think the Syntax is still wrong, or maybe it is not possible to combine if withOLEDB CONNECT TO ??

Kind regards

Philipp

jonathandienst
Partner
Partner

Dont try to do it in an expression. Use this:

If vSQL_INSTANCE = 'TEST' Then

  $(Include=$(path_toggel)CONNECTION_SQL_TEST.qvs);

Else

  $(Include=$(path_toggel)CONNECTION_SQL_PROD.qvs);

End If

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
jonathandienst
Partner
Partner

Or you could try this:

$(Include=$(path_toggel)CONNECTION_SQL_$(vSQL_INSTANCE).qvs);


(BTW -  I would use $(must_include=...) for a connection string so that the script fails at the right place if the include file cannot be found)

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
Not applicable
Author

Thank you so much.

This solved my problem.

Kind regards

Philipp

Not applicable
Author

Good idea!! 🙂

That was not my intention, but works anyway.

Thank you 🙂