Solved

How to assign ORACLE_SID to variable in sqlplus

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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Composite queries are used to retrieve the results from joining multiple queries after applying any filters. UNION, INTERSECT, MINUS, and UNION ALL are some of the operators used to get certain desired results.​
Using SQL Scripts we can save all the SQL queries as files that we use very frequently on our database later point of time. This is one of the feature present under SQL Workshop in Oracle Application Express.
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
This video explains what a user managed backup is and shows how to take one, providing a couple of simple example scripts.

734 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