Solved

How to assign ORACLE_SID to variable in sqlplus

Posted on 2012-03-23
2
1,258 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 77

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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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 post first appeared at Oracleinaction  (http://oracleinaction.com/undo-and-redo-in-oracle/)by Anju Garg (Myself). I  will demonstrate that undo for DML’s is stored both in undo tablespace and online redo logs. Then, we will analyze the reaso…
This video explains at a high level about the four available data types in Oracle and how dates can be manipulated by the user to get data into and out of the database.
This video shows information on the Oracle Data Dictionary, starting with the Oracle documentation, explaining the different types of Data Dictionary views available by group and permissions as well as giving examples on how to retrieve data from th…

756 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