Home » SQL & PL/SQL » SQL & PL/SQL » How to check the database name before executing DDL statements(without using PL/SQL)??
How to check the database name before executing DDL statements(without using PL/SQL)?? [message #19621] Mon, 01 April 2002 20:25 Go to next message
Sreedhar
Messages: 30
Registered: March 2000
Member
Hi,

I am currently using 3 databases on same machine. I got DDL scripts to drop/create tables/views.

Is there anyway to check for the database name before executing DDL scripts???? I want to incorporate this check into script itself, so that I dont have to worry which database I am using. If I am using the wrong database, script should exit saying 'Wrong Database'.

P.S:- Its illegal to use DDL in PL/SQL.

Thanks and Regards
Sreedhar
Re: How to check the database name before executing DDL statements(without using PL/SQL)?? [message #19623 is a reply to message #19621] Mon, 01 April 2002 21:42 Go to previous messageGo to next message
Epe
Messages: 99
Registered: March 2002
Member
Hello,

try "select * from global_names;". You'll have to test it, 'cause I'm not sure how it will behave.

Success,

epe
Re: How to check the database name before executing DDL statements(without using PL/SQL)?? [message #19625 is a reply to message #19621] Mon, 01 April 2002 22:45 Go to previous message
sonali vernekar
Messages: 8
Registered: March 2002
Junior Member
Connected to:
Oracle8 Enterprise Edition Release 8.0.4.0.0 - Production
With the Partitioning and Objects options
PL/SQL Release 8.0.4.0.0 - Production

08:35:10 HCIT>

HCIT is the SID of the database where I am currently connected. Every prompt indicates the time. So when SQL*Plus is done with one command it will display the new time on the prompt for next command. This tells you exactly when the previous command terminated.

How do you set SQL*Plus to do this?

Go to your oracle home directory. e.g.. d:orant.
Go to the SQL*Plus Directory. e.g.. Plus33, Plus80.
Edit or create file Glogin.sql
Add the following text at the end of the file:
set lines 100
set pages 100
set termout off
col dbname new_value prompt_dbname
select substr(global_name,1,instr(global_name,'.')-1) dbname
from global_name;
set sqlprompt "&&prompt_dbname> "
set termout on
set time on

if u come to kno which d/b u r using u dont need to
have a pl/sql for telling u that u r using wrong d/b.

hope this solves ur query.
Previous Topic: How to check the database name before executing DDL statements??
Next Topic: Re: Need SQL for Deleting Tree Data
Goto Forum:
  


Current Time: Fri Mar 29 00:08:16 CDT 2024