From: jstrange@imtn.dsccc.com (John Strange)
Subject: Re: SQL command to determine if DB is open
Newsgroups: comp.databases.oracle.misc
References: <6b0f7239.0108070910.40766f3f@posting.google.com> <SoVb7.27727$jA2.1939219@news20.bellglobal.com>
Organization: Alcatel USA
X-Newsreader: TIN [version 1.2 PL2]
NNTP-Posting-Host: dsun2.usa.alcatel.com
X-Original-NNTP-Posting-Host: dsun2.usa.alcatel.com
Message-ID: <3b716f70$1@news.alcatel.com>
Date: 8 Aug 2001 11:57:20 -0500
X-Trace: news.alcatel.com 997289840 dsun2.usa.alcatel.com (8 Aug 2001 11:57:20 -0500)
X-Original-Trace: 8 Aug 2001 11:57:20 -0500, dsun2.usa.alcatel.com
Lines: 41



/*************************************
*  ck_instance.sql
**************************************/

WHENEVER SQLERROR EXIT sql.sqlcode;
select global_name from global_name@some_instance ;
exit 249

/*********** end ck_instance.sql ******/


On *nix box

sqlplus scott/tiger @ck_instance
if [ $? != 249 ] ; then
  mailx -s "Oracle is down" amw157@aol.com < /dev/null 
fi

On Micro$oft    :(

set ERRORLEVEL=
sqlplus scott/tiger @ck_instance
if %ERRORLEVEL% == 249 goto passed_sql
  (your dos code here)
:passed_sql




: "Andy Weiss" <amw157@aol.com> wrote in message
: news:6b0f7239.0108070910.40766f3f@posting.google.com...
: > I need a quick command that I can execute in SQL Plus to determine if
: > a database is open or not.  Been wading through Oracle's documentation
: > hopelessly for hours.


--
While Alcatel may claim ownership of all my ideas (on or off the job),
Alcatel does not claim any responsibility for them. Warranty expired when u
opened this article and I will not be responsible for its contents or use.

