Return-Path: <root@fatcity.cts.com>
Received: from ensim.rackshack.net (root@localhost)
 by orafaq.net (8.11.6/8.11.6) with ESMTP id g93LH8d16577
 for <oracle-l@orafaq.net>; Thu, 3 Oct 2002 16:17:08 -0500
X-ClientAddr: 209.68.248.164
Received: from newsfeed.cts.com (newsfeed.cts.com [209.68.248.164])
 by ensim.rackshack.net (8.11.6/8.11.6) with ESMTP id g93LH8b16569
 for <oracle-l@orafaq.net>; Thu, 3 Oct 2002 16:17:08 -0500
Received: from fatcity.UUCP (uucp@localhost)
 by newsfeed.cts.com (8.9.3/8.9.3) with UUCP id LAA78843;
 Thu, 3 Oct 2002 11:59:59 -0700 (PDT)
Received: by fatcity.com (26-Feb-2001/v1.0g-b72/bab) via UUCP id 004DFE0F; Thu, 03 Oct 2002 11:43:17 -0800
Message-ID: <F001.004DFE0F.20021003114317@fatcity.com>
Date: Thu, 03 Oct 2002 11:43:17 -0800
To: Multiple recipients of list ORACLE-L <ORACLE-L@fatcity.com>
X-Comment: Oracle RDBMS Community Forum
X-Sender: "Fink, Dan" <Dan.Fink@mdx.com>
Sender: root@fatcity.com
Reply-To: ORACLE-L@fatcity.com
Errors-To: ML-ERRORS@fatcity.com
From: "Fink, Dan" <Dan.Fink@mdx.com>
Subject: RE: RE: svrmgrl echo v$database in script
Organization: Fat City Network Services, San Diego, California
X-ListServer: v1.0g, build 72; ListGuru (c) 1996-2001 Bruce A. Bergman
Precedence: bulk
Mime-Version: 1.0
Content-Type: text/plain;	charset="iso-8859-1"
Content-Transfer-Encoding: 7bit

Dick,
	That is one method. My rule is that all destructive actions are run
from scripts that require the database name as a parameter. If the
$ORACLE_SID and parameter don't match, the script terminates. I realize this
is redundant, but better safe than having to perform a production recovery.
I don't have to code in any database specific values like 'DEV', 'PROD',
etc. so the script can be used for any database. My 'stub' korn shell script
already has this built in, so I don't even have to remember it.
	As an aside, one of the problems I have had with putting this kind
of code in login.sql or glogin.sql is that it causes problems if the
database is not open. I recall spending a few hours troubleshooting a
monitoring script. It would work just fine while we were developing and
testing, but it would fail overnight in the cron job. The database was down
and the glogin.sql script was terminating. To this day, I still don't put
any queries inside login.sql and glogin.sql. One of those things that is
probably fixable, but I'd rather work in improving my Buffer Cache Hit
Ratio.

Dan

-----Original Message-----
Sent: Thursday, October 03, 2002 11:42 AM
To: Fink; Dan; Multiple recipients of list ORACLE-L


Dan,

    You can use a anonymous PL/SQL block like the following in you login.sql
or
script file is necessary, it keeps those errors from happening:

whenever sqlerror exit
declare
  db varchar2(30);
begin
  select global_name into db from global_name;
  if(db not like 'DEV%') then raise_application_error(-20100, "Wrong
Database");
  end if;
end;
/


Dick Goulet

____________________Reply Separator____________________
Author: "Fink; Dan" <Dan.Fink@mdx.com>
Date:       10/3/2002 9:33 AM

What happens if the ORACLE_SID is set to one value and the caller uses
SQL*Net to access a different database? While this is not usually the case
in scripts, it could be a problem if the script is parted of a called
function. 
ORACLE_SID=DEV
sqlplus scott/tiger@PROD  <-- I'm not connected to DEV anymore.

I realize this is nit-picking, but I've done far too many recoveries because
someone thought they were in DEV when they actually connected to PROD. I'd
rather know EXACTLY which db I'm connected to, not which one the O/S thinks
I should be in.

My $.02

Dan Fink

-----Original Message-----
[mailto:Scott.Shafer@dcpds.cpms.osd.mil]
Sent: Thursday, October 03, 2002 9:43 AM
To: Multiple recipients of list ORACLE-L


echo $ORACLE_SID >> logfile

Scott Shafer
San Antonio, TX
210.581.6217


> -----Original Message-----
> From: Baker, Barbara [SMTP:bbaker@denvernewspaperagency.com]
> Sent: Wednesday, October 02, 2002 6:28 PM
> To:   Multiple recipients of list ORACLE-L
> Subject:      svrmgrl echo v$database in script
> 
> 
> Oracle 8.0.5
> Solaris 2.6
> 
> List:
> I've created a script (ksh) called from elsewhere that shuts down the
> database.  I REALLY want to echo the name of the database into my log file
> before I shut down.    While "select name from v$database" works fine from
> svrmgrl interactively, it throws up in the script.  I'd guess the $ sign
> is
> screwing it up.  (I can get other commands to work within the script.)
> However, I don't know what to do about it.
> 
> Any ideas?
> 
> Thx!!!
> 
> Barb
> 
> $ svrmgrl
> 
> SVRMGR> connect internal
> Connected.
> SVRMGR> select name from v$database;
> NAME
> ---------
> TADENT
> 1 row selected.
> 
> 
> #!/usr/bin/ksh
> # $Id: stop_db.sh ver.1 10/02/2002 B.Baker Exp $
> # Name:         stop_db.sh
> # Author:       Barb Baker
> # Purpose:      execute shutdown immediate on current database
> #               (i.e., database pointed to by current value of ORACLE_SID)
> ############################################################
> echo "Stop oracle instance \"${ORACLE_SID}\"  at `date` "
>            ${ORACLE_HOME}/bin/svrmgrl << EOF
>                    connect internal
>                    select name from v_$database;
> EOF
> 
> 
> $  ./stop_db.sh
> Stop oracle instance "tadent"  at Wed Oct  2 16:24:59 MDT 2002
> 
> 
> SVRMGR> Connected.
> SVRMGR>                    select name from v_
>                       *
> ORA-00942: table or view does not exist
> SVRMGR>
> Server Manager complete.
> 
> -- 
> Please see the official ORACLE-L FAQ: http://www.orafaq.com
> -- 
> Author: Baker, Barbara
>   INET: bbaker@denvernewspaperagency.com
> 
> Fat City Network Services    -- 858-538-5051 http://www.fatcity.com
> San Diego, California        -- Mailing list and web hosting services
> ---------------------------------------------------------------------
> To REMOVE yourself from this mailing list, send an E-Mail message
> to: ListGuru@fatcity.com (note EXACT spelling of 'ListGuru') and in
> the message BODY, include a line containing: UNSUB ORACLE-L
> (or the name of mailing list you want to be removed from).  You may
> also send the HELP command for other information (like subscribing).
-- 
Please see the official ORACLE-L FAQ: http://www.orafaq.com
-- 
Author: 
  INET: Scott.Shafer@dcpds.cpms.osd.mil

Fat City Network Services    -- 858-538-5051 http://www.fatcity.com
San Diego, California        -- Mailing list and web hosting services
---------------------------------------------------------------------
To REMOVE yourself from this mailing list, send an E-Mail message
to: ListGuru@fatcity.com (note EXACT spelling of 'ListGuru') and in
the message BODY, include a line containing: UNSUB ORACLE-L
(or the name of mailing list you want to be removed from).  You may
also send the HELP command for other information (like subscribing).
-- 
Please see the official ORACLE-L FAQ: http://www.orafaq.com
-- 
Author: Fink, Dan
  INET: Dan.Fink@mdx.com

Fat City Network Services    -- 858-538-5051 http://www.fatcity.com
San Diego, California        -- Mailing list and web hosting services
---------------------------------------------------------------------
To REMOVE yourself from this mailing list, send an E-Mail message
to: ListGuru@fatcity.com (note EXACT spelling of 'ListGuru') and in
the message BODY, include a line containing: UNSUB ORACLE-L
(or the name of mailing list you want to be removed from).  You may
also send the HELP command for other information (like subscribing).
-- 
Please see the official ORACLE-L FAQ: http://www.orafaq.com
-- 
Author: Fink, Dan
  INET: Dan.Fink@mdx.com

Fat City Network Services    -- 858-538-5051 http://www.fatcity.com
San Diego, California        -- Mailing list and web hosting services
---------------------------------------------------------------------
To REMOVE yourself from this mailing list, send an E-Mail message
to: ListGuru@fatcity.com (note EXACT spelling of 'ListGuru') and in
the message BODY, include a line containing: UNSUB ORACLE-L
(or the name of mailing list you want to be removed from).  You may
also send the HELP command for other information (like subscribing).

