windows batch file : variable assignment [message #358074] |
Sat, 08 November 2008 04:58  |
dr46014
Messages: 49 Registered: February 2007
|
Member |
|
|
I am using Windows to run SQL queries from command prompt.Is there any way to assign the output of a select query to a variable.
I am creating a batch file as mentioned below
c:> type run_oracle.bat
@echo OFF
set MYDIR=C:\oracle\scripts
sqlplus -s user/pwd@DB @%MYDIR%\rpt_dba.sql
exit
the rpt_dba.sql has the below query
SET HEAD OFF
SELECT count(*) from table_name;
While doing the same thing in UNIX i was floowing the below approach
count=`sqlplus -s user/pwd@DB<<EOF
SET HEAD OFF
SELECT count(*) from table_name;
EXIT;
EOF`
export count
How we can create and set count variable in Windows
|
|
|
|
|
Re: windows batch file : variable assignment [message #358077 is a reply to message #358076] |
Sat, 08 November 2008 05:42   |
ThomasG
Messages: 3212 Registered: April 2005 Location: Heilbronn, Germany
|
Senior Member |
|
|
If you have Windows (Windows 2000 or later), then you have the facility to use VB script.
Of course, if you insist on trying to screw in a screw with a shovel instead of getting a screwdriver, then you COULD write an *.cmd file with an pl/sql procedure and then execute that *.cmd file.
[Updated on: Sat, 08 November 2008 05:42] Report message to a moderator
|
|
|
|
|
|
|
|
|
|
|
|
|