Solved

How to assign ORACLE_SID to variable in sqlplus

Posted on 2012-03-23
2
1,248 Views
Last Modified: 2012-03-23
Would like to have the following under sql plus prompt:

1) It worked  
>@test.sql ORACLE_SID
where in test.sql, I can put
define ORACLE_SID=&1
...
I do not want this.

2) Since once logging in database, the ORACLE_SID can be obtained from
select name from v$database;

Is there any way to assign the SID into a define statement in sqlplus?
For example,

>@test.sql
...
define ORACLE_SID = ...
--get the SID via whatever.
...
use the SID in other sql statements.
0
Comment
Question by:jl66
2 Comments
 
LVL 76

Accepted Solution

by:
slightwv (䄆 Netminder) earned 500 total points
ID: 37759546
Look into NEW_VALUE


col name new_value mySid;
select name from v$database;
prompt My Database sid is &mySid

Open in new window

0
 

Author Closing Comment

by:jl66
ID: 37759925
Exactly what I need. Thank you so much.
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I'm trying, I really am. But I've seen so many wrong approaches involving date(time) boundaries I despair about my inability to explain it. I've seen quite a few recently that define a non-leap year as 364 days, or 366 days and the list goes on. …
Confronted with some SQL you don't know can be a daunting task. It can be even more daunting if that SQL carries some of the old secret codes used in the Ye Olde query syntax, such as: (+)     as used in Oracle;     *=     =*    as used in Sybase …
Via a live example show how to connect to RMAN, make basic configuration settings changes and then take a backup of a demo database
Via a live example, show how to take different types of Oracle backups using RMAN.

912 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now