I am using ISQL command in my script like below
echo "going to execute isql for getting JE count"
isql -Uxyz -SSYB_LOCOMOTIVE_xx -Pabc -Dlmn -w300 -o$sumOfJEOutputFile <<EOF
select sum(count(*)) from lmn..ex_je_t where clm_id in ($(cat $finalTemp)) group by clm_id
go
EOF
retval=$?
cat $retval
if [[ $retval != 0 ]]; then
echo "Failed to connect to the Database" | mail -s "ERROR OCCURED:Database connection Failed" "$EXPRS_SUPPORT"
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
I used the if condition so that when there is an error i can exit the script with a message.
But this is not happening,instead i am getting the error printed in my output file.Like this:
Msg 102, Level 15, State 1:
Server 'SYB_LOCOMOTIVE_JE', Line 1:
Incorrect syntax near ')'.
I wonder how the return value of ISQL is 0 when i am getting error instead of proper Output.
Can someone help on this?