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

Announcements
Qlik GA: Multivariate Time Series in Qlik Predict: Get Details
cancel
Showing results for 
Search instead for 
Did you mean: 
mhmmd_srf
Creator II
Creator II

Dynamic ODBC connection is Qlikview

Hi all,

My source is SQL server and database have different password for different environment.

I am trying to handle the ODBC connection dynamically.

I am using below script:

if (wildmatch (v_compName,'100-BIQVW-D*')  then

ODBC CONNECT TO $(vODBC) (XUserId is NYOOWIRNJbaCEEBKNKYEHaVV, XPassword is TOSJTQBNQLbCGZROdF)

else if (wildmatch (v_compName,'100-BIQVW-T*') then

ODBC CONNECT TO $(vODBC) (XUserId is VPXPcIRNJbaCEEBKNKYEHadS, XPassword is BXVQJJVMNbbMXSVJFbbB)

else if (wildmatch (v_compName,'100-BIQVW-P*')  then

ODBC CONNECT TO AHP_PRD (XUserId is VbcAQIRNJbaCEEBKNKYEHaZc, XPassword is BTCDcQBNQLbCGZROZE)

else if (wildmatch (v_compName,'SBYCSQLSCLNT01*')  then

ODBC CONNECT TO $(vODBC) (XUserId is NYOOWIRNJbaCEEBKNKYEHaVV, XPassword is TOSJTQBNQLbCGZROdF

end if

end if

end if

end if


But this is not working.

Can anyone please help me.

Thanks,

Sarif

14 Replies
Peter_Cammaert
Partner - Champion III
Partner - Champion III

Both are allowed by the Script syntax spec. The only difference is that ELSEIF doesn't need repeated END IF statement terminators. An IF with multiple ELSEIF clauses is still a single statement, while ELSE IF starts a new statement, leading to nested IF blocks that each must be terminated.

So you may want to adjust your example code.

Peter_Cammaert
Partner - Champion III
Partner - Champion III

Tres, QV11.20 allows for isolated END IF keywords (as many as you like and wherever you like), but 12.xx gives an error message for your three superfluous END IF terminators. And the message is really informative:

"The control statement is not correctly matched with its corresponding start statement

END IF"

We were warned that QV12 was going to be more strict about script syntax...

tresesco
MVP
MVP

I could remember faintly, that I used both in some earlier version. But with  new qlix engine (QV 12.1) I could not use "else if". I guess, you meant for the older version, right (may be QV 11.2 as you mentioned in the below post)?

Peter_Cammaert
Partner - Champion III
Partner - Champion III

You can use ELSE IF but not on the same line. This

IF var = 1 THEN

  LET Othervar = 'One';

ELSE IF var = 2 THEN

       LET Othervar = 'Two';

     END IF

END IF

doesn't work in 12.xx, but this one

IF var = 1 THEN

  LET Othervar = 'One';

ELSE

  IF var = 2 THEN

    LET Othervar = 'Two';

  END IF

END IF

does.

Also apparently this one doesn't work in v12 anymore, while it used to work in 11.20.

IF var = 1 THEN

  LET Othervar = 'One';

ELSEIF var = 2 THEN

  LET Othervar = 'Txo';

END IF

END IF

mhmmd_srf
Creator II
Creator II
Author

yes...but I am getting error now.