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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to use global variable from SQLPLUS?

Status
Not open for further replies.
Oct 22, 2001
215
US
Hi Gurus!
I am trying to capture a SQL result that is runing/coming from SQLPLUS onto a global variable. I need to read this variable from DOS.

Any help is appreciated!!!
 
Charlie,

It's genuine. He explains his application need in thread186-912778 in the "Oracle: Oracle release - 8i Forum".

Any good ideas?

[santa]Mufasa
(aka Dave of Sandy, Utah, USA @ 05:09 (08Sep04) UTC (aka "GMT" and "Zulu"), 22:09 (07Sep04) Mountain Time)
 
The text of an sql command in temp.sql:
-- temp.sql
set head off feedback off serverout off
var v varchar2(255)
exec :v := your_package_name.your_package_variable
print v
exit


The dos batch file contents in test.bat:
call :gettimestamp currDate
echo currDate is %currDate%

:gettimestamp
for /f %%U in ('sqlplus -s user_schema@sid/password @temp.sql') do set %1=%%U

goto :EOF

From DOS prompt type
>test.bat

You can verify output went to the DOS variable named
currDate with the set command.

HTH,
Charlie ;)
9/7/04
 
Looked for example of assigning a variable to a command
and found something in Cold Fusion stuff and used
>help for

The sqlplus command used from something DIMA posted a while ago on thread759-833580

Globals may be declared in a package spec. No body is
needed.

Charlie ;)
9/7/04
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top