#!/bin/bash
cvalue=$(
$ORAHOME/bin sqlplus "/ as sysdba" <<EOS
set linesize 132
set pagesize 999
set head off
set feed off
select count(*) from dual;
EOS
)
if [ "$cvalue" = 0 ] then
mail -s "zero rows were returned" groking@email.com
fi
The set bits are to remove column headings and so-on from the output, so you just get the row count. You may also want to check the value of $? in case sqlplus was unable to connect to the datbase at all.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.