I am using ISQL command in ksh script.
Suppose if i get NULL value from the query which i run,how can i handle it?
I am getting a NULL result set and the following error is coming.
############### output of isql command for getting the sum of JEs ################
-----------
NULL
(1 row affected)
############ Checking if count is blank ###########
NULL
retrieveCheck.ksh[159]: ^J NULL : 0403-009 The specified number is not valid for this command.
The code is:
blank=""
isql -UUSER -PPW -SSERVER -i$tempSQL2 -w1000 -o$sumOfJEOutputFile
retval=$?
echo $retval
if [[ $retval != 0 ]]; then
echo "Failed to connect to the Archive Database" | mail -s "ERROR OCCURED:Database connection Failed" "akanksha.kumari@libertymutual.com"
exit 0
else
echo "Database connection successful."
fi
echo "coming out of isql command"
echo "############ output of isql command for getting the sum of JEs ################"
cat $sumOfJEOutputFile
egrep -v "row affected|rows affected|------|^ |return status" $sumOfJEOutputFile > $actualCount
#######################################################################
## Assigning the total number of JE count to a variable count
#######################################################################
count=$(cat $actualCount | tr -s "\t" " ")
echo "############## Checking if count is blank #################"
echo $count
if [[ $count -eq $blank ]]; then ## In this line error is coming line number 159
echo "Count is Blank."
exit 0
else
echo "count is not blank"
fi
So i want to know how can i handle this null result set and send a mail to notify that null value is coming.
Thanks
Akanksha