echo off
rem Get_ORA_Status.cmd
rem Obtient le status de la base [ OPEN,MOUNTED,...] et renseigne la variable SID_STATUS
rem Extraction du statut de la base %Oracle_SID%
rem paramétre :
rem %ShortFNStatus% Nom_du_fichier_spool ( résultat )
rem %OraUser% Nom de compte
rem %UserPwd% Password du compte
rem %ORACLE_SID% SID de la base interrogée
"%ORACLE_BIN%\sqlplus" /NOLOG @"%LDTOOLS%\SQL\Get_status.sql" %ShortFNStatus% %OraUser% %UserPwd% %ORACLE_SID%>nul
rem Test des différents résultat de la requête SQL
rem Pas connecté
type "%ShortFNStatus%"|find /i "ORA-01012: not logged on">nul
rem 1 non la chaine n'existe pas.
rem 0 oui la chaine existe.
IF ERRORLEVEL 1 goto suite1
IF ERRORLEVEL 0 Set SID_STATUS=NOTLOGGED&goto fin
:suite1
rem Instance inexistante
type "%ShortFNStatus%"|find /i "ORA-01034: ORACLE not available">nul
IF ERRORLEVEL 1 goto suite2
IF ERRORLEVEL 0 Set SID_STATUS=NOTAVAILABLE&goto fin
:suite2
rem Base non montée
type "%ShortFNStatus%"|find /i "STARTED">nul
IF ERRORLEVEL 1 goto suite3
IF ERRORLEVEL 0 Set SID_STATUS=STARTED&goto fin
:suite3
rem Base montée
type "%ShortFNStatus%"|find /i "MOUNTED">nul
IF ERRORLEVEL 1 goto suite4
IF ERRORLEVEL 0 Set SID_STATUS=MOUNTED&goto fin
:suite4
rem Base ouverte
type "%ShortFNStatus%"|find /i "OPEN">nul
IF ERRORLEVEL 1 goto fin
IF ERRORLEVEL 0 Set SID_STATUS=OPEN&goto fin
rem fin du batch
:fin
set ShortFNStatus=
Partager