After my researches about the methods to connect sqlplus and run an SQL command in a shell script, i wanted to share the results with you.
Here are two methods for this purpose:
1- DB_NAME=$($ORACLE_HOME/bin/sqlplus -s $username/$password << EOF!
select name from v$database;
quit
EOF!
)
echo $DB_NAME > name.log
2- LOCAL_SQL='select name from v$database;'
DB_NAME=`echo $LOCAL_SQL | $ORACLE_HOME/bin/sqlplus -s $username/$password`
echo $DB_NAME > name.log
Both two methods successfully bring SQL command's output to a file. Difference seems to be just syntax. But i'll be pleased if anyone has any experience on this and share with me.
Good Blog. Thanks for sharing this information and helpful for me
Oracle Fusion HCM Online Training
Oracle Fusion SCM Online Training
Oracle Fusion Financials Online Training
Oracle Integration Cloud Online Training
Oracle Fusion Technical Online Training