3 Replies Latest reply: Sep 23, 2015 3:02 PM by Anna Pochyla RSS

    Database connection testing Script

    Krishna Chaitanya Koyyalamudi

      Hello Community Folks,

      I am trying to create a script that tests the database connection .I want variable value to be '0' when database connection fails so that variable value can be used to send email alerts about the connection issue.And I also want to create a qlik table with database name and sysdate as NULL if the db connection fails.Here is the script I created but when I give incorrect db creds in connection string, script is not entering IF block.Can some one correct my script.

       

       

      Set ErrorMode=0;

      Set NullInterpret = '';

       

      LET vDBConnection = 1;


      Trace 'Now Testing DBConnection';

       

      OLEDB CONNECT TO [Provider=OraOLEDB.Oracle.1;Persist Security Info=True;User ID=xxxxx;Data Source=xxxx;Extended Properties=""] (XPassword is xxxxxx);

       

      StreamHist:

       

      SQL SELECT  'Databse Name' as DBNAME,SYSDATE FROM DUAL;

       

      LET DBconnection_DATE =PEEK('SYSDATE',0,'StreamHist');

       

      IF DBconnection_DATE = '' THEN

       

      LET vDBConnection = 0;

       

      StreamHist:

       

      LOAD * INLINE [

          DBNAME, SYSDATE

          'Databse Name'

      ];

       

      ENDIF

       

      exit script;