Index: trunk/DataCheck/Monitoring/CheckStatus.sh
===================================================================
--- trunk/DataCheck/Monitoring/CheckStatus.sh	(revision 13578)
+++ trunk/DataCheck/Monitoring/CheckStatus.sh	(revision 13579)
@@ -36,11 +36,16 @@
    query="SELECT Count(*) FROM "$step"Status "$where
    num=`sendquery`
-   if [ $num -gt 0 ]
-   then
-      printprocesslog "WARN found in "$step" "$num" rows with errors."
-      sel=$selstart", '(', fReturnCode, ')')"
-      query="SELECT "$sel" FROM "$step"Status "$where
-      sendquery | mail -s 'found failed jobs in '$step $erradrs
-      printprocesslog "INFO sent mail about failed jobs in "$step" to "$erradrs
+   if [ "$num" == "" ]
+   then 
+      printprocesslog "WARN could not get number of failed jobs from the DB."
+   else
+      if [ $num -gt 0 ]
+      then
+         printprocesslog "WARN found in "$step" "$num" rows with errors."
+         sel=$selstart", '(', fReturnCode, ')')"
+         query="SELECT "$sel" FROM "$step"Status "$where
+         sendquery | mail -s 'found failed jobs in '$step $erradrs
+         printprocesslog "INFO sent mail about failed jobs in "$step" to "$erradrs
+      fi
    fi
 
@@ -54,11 +59,16 @@
    query="SELECT Count(*) FROM "$step"Status "$where
    num=`sendquery`
-   if [ $num -gt 0 ]
-   then
-      printprocesslog "WARN found in "$step" "$num" crashed jobs."
-      sel=$selstart", '(', fStartTime, ')')"
-      query="SELECT "$sel" FROM "$step"Status "$where
-      sendquery | mail -s 'found crashed jobs in '$step $erradrs
-      printprocesslog "INFO sent mail about crashed jobs in "$step" to "$erradrs
+   if [ "$num" == "" ]
+   then 
+      printprocesslog "WARN could not get number of crashed jobs from the DB."
+   else
+      if [ $num -gt 0 ]
+      then
+         printprocesslog "WARN found in "$step" "$num" crashed jobs."
+         sel=$selstart", '(', fStartTime, ')')"
+         query="SELECT "$sel" FROM "$step"Status "$where
+         sendquery | mail -s 'found crashed jobs in '$step $erradrs
+         printprocesslog "INFO sent mail about crashed jobs in "$step" to "$erradrs
+      fi
    fi
 done
