0

how to execute sql query or script using sqlplus as the middle man and insert output to bash variable?

1 Answer 1

1

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 
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.