I have written a script so that i can read from an oracle database and display it once i run the script. Is there any way that I can transfer the result to unix variable?
$ORACLE_HOME/bin/sqlplus -s /nolog<<EOF
connect useid/password@CFQ143
set pages 0 feed off
select count (platform) from platformspecific where platform='EF';
exit
EOF
I found the answer - rather than use single quotes to pass the value to a variable, you can use open and close brackets to transfer the values:
var=$($ORACLE_HOME/bin/sqlplus -s /nolog<<EOF
connect useid/password@CFQ143
set pages 0 feed off
select count (platform) from platformspecific where platform='EF';
exit
EOF)
echo $var
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.