Alert notification/Trigger on NO Data or Data Stalls

Question: I have a table say 'scd_reading' where the data is inserted every 15 seconds. the data is in the following format:

Time                                   mwr                  value

18-APR-10 06:15:00           24                     23
18-APR-10 06:15:15           26                     22
18-APR-10 06:15:30           23                     21
18-APR-10 06:15:45           23                     14

There are two undesired things that could happen sometimes

1. There is no data being updated to this table
2. The readings may start stalling at a point. ie the columns 'mwr' and 'value' may be showing the same readings for every subsequent 15 seconds.

I am looking to write a trigger to monitor this every half hour and fires

1. when there is no data update and writes a message say 'no data update' to the table called 'alert_tab'. ie when the trigger runs every half hour and if there is no data update in the past 5 min at the time it runs.

2. To write a message 'the reading stalled' when the reading stalls, that is past 10 readings for 'mwr' column and  'value' column are same at the time the trigger runs.

I am gonna schedule a  report to run against 'alert_tab' table every half hour just after a minute the trigger is shceduled to run and catch any messages that may have populated in the table and send an alert notification to the user. I can reset this table when I run the report.

I need help writing a trigger to do as described above. If there are any better methods available to send an alert to the user..please let me know. I am using Oracle 10g database.

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

slightwv (䄆 Netminder) Commented:
I'm not sure you can do this with a trigger.  Triggers need some event to fire them and I don't think you can tie one to changes in time.

I believe what you need is some stored procedure and a database JOB set up through DBMS_SCHEDULER.

What are you thinking for the 'alert'?  You can have the database send an email using UTL_MAIL to any user for any reason.

Putting it all together:
Create a procedure that sends an email and schedule it to run every 30 minutes.

There are tons of links out there on all these topics.  If you have specific questions or run into problems just let us know.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
" monitor this every half hour "

Write a procedure and chedule a job as slightwv suggests.
gs79Author Commented:
Can you please provide me with a sample script or links explaining writing such procedures to send emails using utl feature along with scheduling the job..

slightwv (䄆 Netminder) Commented:
There are already tons of examples out there.  They can provide as good an example as we could here since we don't know the exact details of your system.

Start with the online docs then Google UTL_MAIL and DBMS_SCHEDULER.

If you need help with the SQL to determine if the email should be sent or help with any error you are getting when you try to work through the examples, just let us know.

gs79Author Commented:
I didnt get a chance to implement this. I may play with the tutorials sometime later. We used someother application to monitor which was already in place..

Thanks for the suggestions..
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Oracle Database

From novice to tech pro — start learning today.