Hello,
Here are the script, sql file and the log file that gets generated.
Thanks for helping me out -----
***Contents of scott_query_database.sql **********************
set feedback off;
set heading off;
spool scott_query_database.log
Prompt The total number of records in emp table is
select count(*) from emp;
Prompt The current value of sequence EMP_SEQ is
select last_number - cache_size "EMP_SEQ"
from user_sequences where sequence_name = EMP_SEQ';
spool off
set heading on;
set feedback on;
************************************************** ****
***Contents of scott_query_database.sh *************************
#!/bin/ksh
sqlplus -s scott/tiger <<-SQL
@scott_query_database.sql
exit
SQL
cat - scott_query_database.log <<! >/tmp/mail.msg
To:
mansac@rediffmail.com
Subject: ALERT: A MESSAGE FROM SERVER01
!
mailx -r "DBUSER@`hostname`" -t </tmp/mail.msg
************************************************** ****
**Contents of scott_query_database.log *************************
The total number of records in emp table is
22
The current value of sequence EMP_SEQ is
2998
************************************************** ****