Script not spooling in the designated file.

Hi, I need to write a script that will run a simple select count(*) query and sends the result of that query to me via email.

Here's what I already have.

#!/bin/ksh
######################################################################
# File Name  : counts.sh
# Created    : 2019/27/19
# Author     : 
#-----------------------------------------------------------------------
# $Revision: 1.0 $
# $Date: 2019/01/27 08:00:00 $
#-----------------------------------------------------------------------
# Modification History:
# No      Date       Author         Note
#
#-----------------------------------------------------------------------
#
#
########################################################################
DB_USERNAME=$1
DB_PASSWORD=$2
DB_DBASE=$3

#------------------------------------------------------------
# Start Log
#------------------------------------------------------------
DB_CONN=${DB_USERNAME}/${DB_PASSWORD}@${DB_DBASE}
LOG_DATETIME=`date +%Y-%m-%d:%H:%M:%S`
LOG_FILE=/tmp/$LOG_DATETIME.log
EGREP=/bin/egrep
ORA_ERR_STR=ORA

#==Start Counting ========================================

sqlplus -S ${DB_CONN} > $LOG_FILE << ORAEND

set serveroutput on;
set feedback off
SPOOL /tmp/counts.txt
PROMPT COUNTS

SELECT COUNT(*) FROM schema.db;

spool off;
ORAEND


mailx -s "Counts on $DB_DBASE is" user@gmail.com < /tmp/counts.txt		
#===end of script=========#

I'm calling the script using

The script is already sending an email "Counts on $DB_DBASE is" without the actual result of the query.
I'm a total stranger in Shell scripting and just basing my work on the existing scripts in our project.

what is in this file?
To see try:

cat /tmp/counts.txt

I would suspect that the $ORA_HOME variable (or one of its cousins) or your $PATH variable is not set correctly. the env command will show you all of your environment variables.

Next:
Change the way you run the script the script and run it. See if you get errors.

./counts.sh

Note the dot preceding the slash. This fixes temporarily problems with your PATH environment variable