You can use a ksh script similar to the one below. Just make sure that you include "WHENEVER SQLERROR EXIT SQL.SQLCODE" as one of the first few lines of your SQL script. This will ensure that you get a non-zero status when an error occurs.

======doit.ksh======
#!/bin/ksh

logfile=/tmp/log.$$

exec > $logfile 2>&1
sqlplus -s username/password@db @doit.sql
let res=$?
if (( $res != 0 )) ; then
___mailx -s "the subject" [email protected] < $logfile
fi
====end of doit.ksh====

====doit.sql=====
WHENEVER SQLERROR EXIT SQL.SQLCODE
select count(*) from dba_objects
/
exit
====end of doit.sql=====