finding difficult to check a condition

Hi all,
I have a condition
if(($x>0))
then echo "ok"

x=`sqlplus -s dmiapp/dmiappl_04@dmid << EOF
SELECT count(*) FROM $TABLE_NAME
exit
EOF`

Now the problem occurs when the above code returns an error message (RETURNs a string )as database is down.

I have created the script for checking the database is down or up.
Please give some clue.

Regards
Megh

Yes,
try this:

x="$(sqlplus -s << EOF
user/pass@service
set pages 0 feed off
SELECT ltrim(count(*)) FROM $TABLE_NAME;
EOF
)"

case $x in 
  "" | *[!0-9]* ) printf "Invalid number: %s\n" "$x";; 
              * ) (( $x > 0 )) && printf "OK\n" || printf "KO\n";; 
esac

P.S. I wouldn't post database username and password on a public forum :slight_smile: