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

Announcements
Want to see what's currently in public preview? We've pulled it all together in one place. Check it out here
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Stop Script execution when not connected with database

Im using ODBC CONNECT32 TO [$(vDbInstance);DBQ=$(vDbInstance)] (UserId is $(vDbUsername), Password is $(vDbPassword)); to connect to my database. How to handle when database conneciton not available ?

set ErrorMode=0;

ODBC CONNECT32 TO [$(vDbInstance);DBQ=$(vDbInstance)] (UserId is $(vDbUsername), Password is $(vDbPassword));

if ScriptError >= 1 then   // or ScriptError > 1

     //no connect...

          CALL Log('WARN:Error in commection -  ' & '$(vDbInstance)' & ',cannot continue' );

    exit Script;

end if

Script execution says

Failed to connect

Error Msg Box

SQL##f - SqlState: S1000, ErrorCode: 12541, ErrorMsg: [Oracle][ODBC][Ora]ORA-12541: TNS:no listener

  ODBC CONNECT32 TO [dim74t1;DBQ=dim74t1] (UserId is IBI, Password is IBI)

Labels (1)
4 Replies
disqr_rm
Partner - Specialist III
Partner - Specialist III

Would pingin the server help you?

http://community.qlik.com/message/80817#80817

Not applicable
Author

Thanks Rakesh , will try that.

any Idea why it didnt catch up wtih ErrorCode >1 ?

rbecher
Partner - Master III
Partner - Master III

Hi,

you could use the Oracle program tnsping:

//Load Script:

execute cmd.exe /C "tnsping dim74t1 >tnsping.out";

tnsping:

LOAD @1

FROM tnsping.out (txt, codepage is 1252, no labels, delimiter is '\t', no quotes)

WHERE left(@1,9)='TNS-12541';

IF NoOfRows('tnsping') THEN

    TRACE TNS:no listener;

     exit script;

END IF

- Ralf

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

Thanks Ralf