Capture Oracle return code in shell script

I am using the following code in my shell script

list=`sqlplus -s $user/$pwd@$dbms<<EOF
WHENEVER SQLERROR EXIT SQL.SQLCODE
set pagesize 0 feedback off verify off heading off echo off

select * from control_tbl
where src_nm=$3
and extrct_nm=$4;

exit SQL.SQLCODE;
EOF`

ERROR=$?
if [ ${ERROR} -ne 0 ]
then
echo "Failure" >> $LOGFILE
else
echo "Success" >> $LOGFILE
fi

Problem I am facing is, it does not log a 'success' or 'failure'. It simply skips the above if loop, even though the list variable contains resultset from oracle table.

Can anybody help me understand what exactly the problem is and how I can fix it?

Appreciate all the help, folks

Thanks
Vikas.

list=`sqlplus -s $user/$pwd@$dbms<<EOF
WHENEVER SQLERROR EXIT FAILURE
set pagesize 0 feedback off verify off heading off echo off

select * from control_tbl
where src_nm=$3
and extrct_nm=$4;
EOF`

ERROR=$?
if [ ${ERROR} -ne 0 ]
then
echo "Failure" >> $LOGFILE
else
echo "Success" >> $LOGFILE
fi