Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Return of the value into a variable.

Status
Not open for further replies.

Yarka

Technical User
Jan 14, 2007
192
ES
Hi,
I have to do a same query time to time. This query only return a value. How can it value is returned to a variable in batch script?.
For example:
set my_value = sqlplus user/pass @query
but it doesn't work.

Thanks.
 
Yarka,

After my_value receives a result from "@query", how do you plan to use my_value? Is my_value used in another query? Is it used outside of Oracle?

If possible, please show us your code that uses my_value after it receives the result from "@query".

Thanks,

[santa]Mufasa
(aka Dave of Sandy, Utah, USA)
[I provide low-cost, remote Database Administration services: www.dasages.com]
 
I need value of my_value outside of Oracle, inside of a script. I know to put it into a file but I don't know to put it into variable.
 
Yarka said:
I need value of my_value outside of Oracle, inside of a script.
If you are not using the value inside of Oracle, what is the language of the non-Oracle script?


I frequently pass data from Oracle to non-Oracle scripts by causing Oracle SQL to write the entire non-Oracle script (including variable values) to disk. Then I invoke the non-Oracle script (which Oracle SQL writes) by the non-Oracle environment.

Does this technique sound like it would work for you, Yarka?

[santa]Mufasa
(aka Dave of Sandy, Utah, USA)
[I provide low-cost, remote Database Administration services: www.dasages.com]
 
The language of the non-Oracle script is batch script.
I need to do a query to a database. I use sqlplus. After the result of this query (in my case, it ever is a only number) is compared with other variables of the script. I know how to do it using for Linux/Unix (bash script) but no using Windows (batch using).

 
Yarka,

Can you please post a sample of the Windows batch script (including the result of the query)?

[santa]Mufasa
(aka Dave of Sandy, Utah, USA)
[I provide low-cost, remote Database Administration services: www.dasages.com]
 
hi,
I still have the same problem.

For example my query is:

select 100 - trunc(b.free/a.total * 1000) / 10 prc from ( select tablespace_name,sum(bytes)/1024/1024 total from dba_data_files group by tablespace_name) A, ( select tablespace_name,sum(bytes)/1024/1024 free from dba_free_space group by tablespace_name) B where a.tablespace_name=b.tablespace_name and a.tablespace_name='SYSTEM';

and a possible result is: 95.58

Thanks.
 
You may run something like

Code:
select 'set variable='||actually_selected_value ...

spool to the file (don't forget to issue SET HEADING OFF and probably sme other off's) and execute this file.



Regards, Dima
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top