how to execute sql query or script using sqlplus as the middle man and insert output to bash variable?
nothing worked for me of the (at least) 3 good looking stack-overflow and other websites tutorials so I'm posting what worked for me, for the of chance that it will be useful to some one else.
the code:
#!/bin/bash
export ORACLE_SID=<DB_SID>
VAL=""
VAL=`sqlplus -s / as sysdba << EOF
whenever sqlerror exit sql.sqlcode;
set echo off
set heading off
@<sql_script_path>
exit;
EOF`
echo $VAL
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.