Home » Infrastructure » Unix » How to send the result of a sqlplus query to a shell variable
How to send the result of a sqlplus query to a shell variable [message #137768] Fri, 16 September 2005 12:03 Go to next message
sinbyrne
Messages: 2
Registered: September 2005
Junior Member
Hi I am running the following bsh script.

sqlplus -S $elw_id/$elw_password@uat << STOP > S1

set heading on pagesize 100 linesize 100 tab off
set feedback off
Select count(*) from cv_welcome where market = 'SFE'
/
quit
STOP

this sends the output to a file S1 in my working directory.
What I really want is to send this to a shell variable.

Any ideas?


Thanks
Re: How to send the result of a sqlplus query to a shell variable [message #137770 is a reply to message #137768] Fri, 16 September 2005 12:54 Go to previous message
Art Metzer
Messages: 2480
Registered: December 2002
Senior Member
Note the use of the backtick (CHR(96)):
my_var=`sqlplus -s $elw_id/$elw_password@uat << STOP
SET TRIMSPOOL ON HEADING OFF PAGESIZE 100 LINESIZE 10 TAB OFF FEEDBACK OFF
SELECT COUNT(*) FROM cv_welcome WHERE market = 'SFE'
/
EXIT
STOP`
echo "$my_var"
Previous Topic: Help in Shell Scripting
Next Topic: How to send an sqlplus output to shell variable
Goto Forum:
  


Current Time: Wed Apr 24 21:06:55 CDT 2024