Try something like this:
sqlplus ${OP_CONNECT_STRING}@${OP_ORA_INST} @sqls/sel_logical_dt.sql > logical_dt.log
rc=$?
if [ $rc -eq 0 ]
then
ANSWER=`cat logical_dt.log`
else
# In this case there will be an error
ANSWER=""
fi
echo $ANSWER
==============================
Don't forget in your sql:
set heading off
set pagesize 0
set feedback off
set verify off
set termout off
set timing off
set wrap on
WHENEVER SQLERROR EXIT SQL.SQLCODE
==============================
Without error-detection:
ANSWER=`sqlplus ${OP_CONNECT_STRING}@${OP_ORA_INST} @sqls/sel_logical_dt.sql`
That worked fine... The only problem with redirection is that the output file contains the verbiage when you connect and exit from oracle. However, I used the AWK command to strip out what I needed.
Bookmarks