I have to design something that will send an automatic email if the count of records in a particular table is more than 100 records? Can you please suggest some ways to implement this?
I can think of one; where i can write a batch job that will scan the table for number of records; if the number of records > 100 trigger a new job to send the email to a group (by writing to internal reader). Also, I have to schedule the batch job to run periodically, lets say every 15 mins to monitor the count of records in the table.
Is there an easier way to accomplish this with lesser load on the system? or Avoid Batch job.
This is for an order processing system and purpose of this is to automate the monitoring of the system health. incase the order processing server is down, the orders will not be generated. Incase the orders are not generated and the backlog is more than 1000 or 5000 orders , it should send an email to the concerned person so that corrective action can be taken.
I get your point when you say that the count should be verified when the insert happens.
Also, i have a similar concern that there will be so many emails generated. For that i guess i will try to save the timestamp of last sent email - if an email was sent in last 15 mins; do not send a new email.
Joined: 14 Jan 2008 Posts: 2504 Location: Atlanta, Georgia, USA
When you say "Table" is this an in-core Assembler CSECT that accumulates data or is it a storage-table (LINKAGE or WS) in the target program itself?
You could have a separate "Traffic Cop" started task (starts every 30 seconds or so), which interrogates this table and when it has reached or has exceeded 100, start a separate started task (different transid), which builds and submits an IEBGENER Job (via the SPOOL API's), which will notify the e-Mail recipient.
Or, just add code to the program which contains the table and build/submit the IEBGENER Job (via this same started task as just mentioned) when the table count is not less than 100.
But, you really need to explain this "table" concept a little better, so we can provide other scenarios.
A separate started task addressing table-storage of a completely different program can be done, but not easily.