I am stuck with a script where it has to send the notification mail only when select query returns some rows. If my select query returns zero rows it should not send me any mails.
I am briefing up the below script which runs through cron.
It would be a great sort of help if you can analyze and help me with a solution.The script is executing successfully but please help me with this requirement of sending mails when select query returns more than zero records.
I am eagerly waiting for your response.Please kindly do the needful.
- Code: Select all
##Logs into all the databases automatically in the server.
sqlplus -s "/ as sysdba" <<EOF>$LOGFILE
set feed off;
set define ~
set echo on;
SET PAGESIZE 200
spool path/name.log append;
select sysdate from dual;
select host_name,instance_name,version from v\$instance;
select name from v\$database;
DROP TABLE owner.tablenameX1;
CREATE TABLE "owner"."tablenameX1"( columns );
FROM table 1
WHERE table_name in ( select table_name from table2 )
AND condition ;
Truncate the tablenameX1.
INSERT INTO owner.tablenameX1 (column names)
VALUES (from variables declared);
select columns from owner.tablenameX1 group by columns having condition order by 3;
cat $WEEKLY_LOG | mailx -s "subject : Description " $DBA