@echo off rem ----------------------------------------------------------------------- rem Filename: dbup.bat rem Purpose: Check if database is up and running rem Notes: When using Oracle releases prior to 8i, replace "sqlplus" with rem "plusXX" in the script below. XX is the version number, eg. 73 rem or 80. This is needed as sqlplus (in these releases) will start rem a new window and the return code will be lost. With Oracle 8i rem sqlplus executes in the same window as the rest of the script. rem Date: 05-Mar-2002 rem Author: Frank Naude, Oracle FAQ rem ----------------------------------------------------------------------- rem -- Set Database SID --- set ORACLE_SID=sgnt rem -- Create SQL Script --- echo connect sys/orcl as sysdba; > %0.tmp echo set echo off feed off pages 0 >> %0.tmp echo whenever sqlerror exit sql.sqlcode >> %0.tmp echo select * from global_name; >> %0.tmp echo exit; >> %0.tmp rem -- Test connect to database --- sqlplus -s /nolog @%0.tmp >NUL: if {%ERRORLEVEL%} == {0} ( echo Database %ORACLE_SID% is available ) else ( echo Database %ORACLE_SID% is NOT available ) rem -- Cleanup -- del %0.tmp