Solved

How to assign ORACLE_SID to variable in sqlplus

Posted on 2012-03-23
2
1,244 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.

Join & Write a Comment

Suggested Solutions

I remember the day when someone asked me to create a user for an application developement. The user should be able to create views and materialized views and, so, I used the following syntax: (CODE) This way, I guessed, I would ensure that use…
This article describes how to use the timestamp of existing data in a database to allow Tableau to calculate the prior work day instead of relying on case statements or if statements to calculate the days of the week.
Via a live example, show how to restore a database from backup after a simulated disk failure using RMAN.
This video explains what a user managed backup is and shows how to take one, providing a couple of simple example scripts.

747 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

10 Experts available now in Live!

Get 1:1 Help Now