4 Replies Latest reply: Jan 23, 2012 12:27 AM by Jagan Mohan RSS

    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)