DB2 and Unix Variable .....

Guys Quick help...

----------------------------
#!/usr/bin/ksh

db2 -x "select count(*) from ${SCHEMA}.EMP"> $HOME/count.dat
COUNT=`cat $HOME/count.dat`
echo Table Count: $COUNT

if ( $COUNT -eq 0 ); then
echo Record Count in Table is 0
exit 1
fi
echo Records Exist
----------------------------

The above script gives error:

Table Count: 0
./test.ksh[8]: 0: not found.
Records Exist

can i get a quick resolution....

Use square brackets in your 'if' statement

you can also set the COUNT variable in one step.

db2 -x "select count(*) from ${SCHEMA}.EMP" | read COUNT

if [[ ${COUNT} -eq 0 ]]; then
   echo "Record Count in Table is 0"
   exit 1
else
   echo "Records Exist"
fi