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

Home -> Community -> Mailing Lists -> Oracle-L -> RE: aborting a SQL script based upon DB name

RE: aborting a SQL script based upon DB name

From: Igor Neyman <ineyman_at_perceptron.com>
Date: Thu, 19 May 2005 10:17:07 -0400
Message-ID: <001301c55c7d$7083cb40$2004a8c0@development.perceptron.com>


Same idea, but instead of aborting I do conditional dynamic sql:

declare

   dbname global_name.global_name%TYPE; begin

   select global_name into dbname

      from global_name;

   if dbname = 'LVLSDP' then

        EXECUTE IMMEDIATE '..............';
   end if;
end;
/

Igor Neyman, OCP DBA
ineyman_at_perceptron.com

-----Original Message-----
From: oracle-l-bounce_at_freelists.org
[mailto:oracle-l-bounce_at_freelists.org] On Behalf Of Greg Norris Sent: Thursday, May 19, 2005 8:50 AM
To: ORACLE-L
Subject: aborting a SQL script based upon DB name

I was recently asked how to setup a SQL script, to ensure that it aborts if accidentally run on the wrong database. The scriptlet below is what I came up with... it seems to work just fine, but got me curious about alternate approaches. Anyone care to share a substitute, or comment on the futility of life in general? ;-)

declare

   dbname global_name.global_name%TYPE; begin

   select global_name into dbname

      from global_name;

   if dbname !=3D 'LVLSDP' then

      raise_application_error(-20001,'I pity ''da fool who connects to ''da wrong database!!!');

   end if;
end;
/

--=20
"I'm too sexy for my code." - Awk Sed Fred.

--
http://www.freelists.org/webpage/oracle-l


--
http://www.freelists.org/webpage/oracle-l
Received on Thu May 19 2005 - 10:25:48 CDT

Original text of this message

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