SQL Query email automation

How do I write a cron which will run a SQL query and mail the results to a group?

Showing Answers 1 - 2 of 2 Answers

Kalyan

  • Oct 18th, 2005
 

Use DBMS_JOB for scheduling a cron job and DBMS_MAIL to send the results throught email.

  Was this answer useful?  Yes

Create sql file name_of_file.sql

In name_of_file.sql file

output to pipe 'mailx -s "SUBJECT"  mail_recepient' select * from table;


Create a unix script name  "whatever"

#!/bin/bash
#  whatever
#  source in Informix environment

. /opt/informix/informix.rc

# cd to location of name_of_sql.sql

cd /home/informix/sql

$INFORMIXDIR/bin/isql -qcr dbname@$INFORMIXSERVER  ./$1


crontab entry

0 5 * * * . ~/.cron_profile;$HOME/scripts/whatever  name_of_file 1>/dev/null 2>&1

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions