Issues while sending a mail having records fetched from SQL -all in UNIX

hi-I want to write a UNIX Script which will fetch records from Oracle database.I want to store these records in a file under fields like email address,name and the transaction_id and then fetch these records from the file and send the email to individual users with their transaction ID details.

More than likely you'll need to use a language like Python, Perl, or C to abstract that data.

Code is like

#######################################################################
# Starting the JOB
#######################################################################
#LIST=`ls ${LOG_HM}/${JOB_NM}*.*`

echo "JOB:$JOB_NM started at $DATETIME_NOW" > ${LOGFILE} 2>&1
echo " " >> ${LOGFILE} 2>&1

######################################################################
# Setup Connection String for Connecting to Oracle #
######################################################################
if [[ ! -a $HOME/.pass_]]; then
echo "Password File $HOME/.pass doesn't exist" >> ${LOGFILE} 2>&1
echo "Returning Non-Zero Code" >> ${LOGFILE} 2>&1
exit 1;
fi
USER=`cat $HOME/.pass | cut -d'/' -f1`
PASSWD=`cat $HOME/.pass_cdm | cut -d'/' -f2`
CONNECT_STRING=$USER/$PASSWD


ble.
#***********************************************************************

*******************************************
function Search_And_Mail_To_DS
{
sqlplus -s <<//
$CONNECT_STRING
set verify off
set heading off

COLUMN param FOLD_AFTER

SELECT trnsctn_nbr ,FRST_NM ,eml_adrs
FROM systm_usr
WHERE
UPDT_DT like sysdate


SET HEAD ON FEEDBACK ON VERIFY ON
COLUMN param CLEAR
PROMPT sql_complete
exit;


while read -p LINE
do
# Start setting variables based on return values
if print $LINE | grep @yahoo.com
then
INPUT_RECORD_SIZE=$(print $LINE | awk -F: '{print $2}')
continue

# Process any Oracle errors

elif print $LINE | grep x
then
print "Oracle error occurred"
exit 1

# Start setting variables based on return values
elif print $LINE | grep @
then
INPUT_RECORD_SIZE=$(print $LINE | awk -F: '{print $2}')
continue

# Look for our loop termination marker and break out when found
elif print $LINE | grep sql_complete
then
break


fi
done
//

if [ ${?} -ne 0 ]; then
echo "Failed To Connect To Oracle" >> ${LOGFILE} 2>&1
echo "Returning Non-Zero Code" >> ${LOGFILE} 2>&1
exit 1;
fi

}


#***********************************************************************

*****************************************
#archive_log_files $LIST
echo "Global IDs for which NULL values are passed from WFSAD while 

update" >> ${LOGFILE} 2>&1
echo 

"-----------------------------------------------------------------------

--" >> ${LOGFILE} 2>&1
Search_And_Mail_To_DS>> ${LOGFILE} 2>&1
echo 

This code doesnt work

To keep the forums high quality for all users, please take the time to format your posts correctly.

First of all, use Code Tags when you post any code or data samples so others can easily read your code. You can easily do this by highlighting your code and then clicking on the # in the editing menu. (You can also type code tags

```text
 and 
```

by hand.)

Second, avoid adding color or different fonts and font size to your posts. Selective use of color to highlight a single word or phrase can be useful at times, but using color, in general, makes the forums harder to read, especially bright colors like red.

Third, be careful when you cut-and-paste, edit any odd characters and make sure all links are working property.

Thank You.

The UNIX and Linux Forums

I can see the records being fetched as it can be viewed in the logs,but theeafter I need to mail them (-might be through a Do while loop) to individual user with their ids ...but dont know how...