Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

sqlplus 'whenever' and standard error

794093Aug 31 2010 — edited Aug 31 2010
I want to capture any SQLPlus errors from my script, and treat them separately from
when I get "normal" output.

It appears to me that SQLPlus is returning SQL errors to standard output, not standard
error. Is this correct? I tried using "2>~/tmp/rstats_output.txt" but did not get anything.

Here is what I am using:


sqlplus -s ${FW_DB_USER}/${FW_DB_PASSWD}@${FW_DB_SID} >~/tmp/rstats_output.txt <<EOF
whenever sqlerror exit sql.sqlcode
set heading off
SELECT COUNT(cust_num)FROM BL_DATA WHERE(disconnect_date IS NULL OR disconnect_date >= SYSDATE);
EOF

if [ "$?" != "0" ]
then
echo "Statistics report failed"
echo "SQLPlus error returned $?"
cat ~/tmp/rstats_output.txt | /bin/mailx -s "Statistics Report FAILED for `date +%D`" myemail@mydomain.com
fi
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 28 2010
Added on Aug 31 2010
4 comments
1,451 views