Help Needed in Sh script

hi,

Im trying to select from a sql using shell script and once i get count i need to add the count to the subject line and send mail to every1..

ex :
Select count(*) from emp;

In Shell script

echo $PASSWORD|$ORACLE_HOME/bin/sqlplus $USERID@$DBNAME @$SCRIPT_DIR/emp_count.sql >>$LOGFILE
and then im
need to send an email to everyone with the count in the subject line...

Please help me how i can send it

Check this example:

# cat SQLScript.sql
SET FEEDBACK OFF
SET HEAD OFF

SELECT 1 FROM DUAL;

EXIT

# dbResult=`sqlplus -S -L <DBUser>/<DBPass>@${ORACLE_SID} @SQLScript.sql | sed 's/ //g'`
sqlRetCode=$?

# echo ${dbResult}
1

I would suggest you to test the sqlplus return code:

if [ ${sqlRetCode} -ne 0 ]
then
     echo "Failed to execute SQL statement."
     exit 1
fi

I hope it helps!