Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.tools -> Re: SQL command to determine if DB is open

Re: SQL command to determine if DB is open

From: Stephen Bell <stephen.bell_at_cgi.ca>
Date: Wed, 8 Aug 2001 10:39:31 -0400
Message-ID: <39cc7.31279$5c.2218436@news20.bellglobal.com>

Okay then!

Would a funtion like this help?

CREATE OR REPLACE FUNCTION CK_STATUS
RETURN BOOLEAN AS

V_STATUS VARCHAR2(10); BEGIN SELECT STATUS
INTO V_STATUS
FROM V$INSTANCE; IF V_STATUS = 'OPEN' THEN RETURN TRUE; ELSE RETURN FALSE; END IF;
END; Then,

Function created.

SQL> SET SERVEROUTPUT ON
SQL> BEGIN
  2 IF CK_STATUS THEN
  3 DBMS_OUTPUT.PUT_LINE ('IT IS OPEN');   4 ELSE
  5 DBMS_OUTPUT.PUT_LINE('NOT OPEN');
  6 END IF;
  7 END;
  8 /
IT IS OPEN PL/SQL procedure successfully completed.

I know...now you're going to say that it doesn't just apply to the current database right? You have to test a whole bunch of databases? :)
"Andy Weiss" <amw157_at_aol.com> wrote in message news:6b0f7239.0108080617.5e6e3a52_at_posting.google.com...
> > If I understand you correctly, how about using something like the
 v$instance
> > view (described next)
>
> I guess I should have been more specific. I need to do this from
> within a batch file. In other words, if the database is open, do
> these steps; if the database is not open, do these other steps.
>
> I don't think v$instance will do the trick for me. I need a statement
> that returns to me a boolean or an integer that tells whether the
> result of the statement was true or false.
>
> Andy
Received on Wed Aug 08 2001 - 09:39:31 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US