Link to home
Start Free TrialLog in
Avatar of Roberto Madro R.
Roberto Madro R.Flag for United States of America

asked on

Stay Alert!

I'm looking for ideas on generating an alert of Oracle 9i based on specific value entered into a specific table.

Any idea.

Thx
Avatar of jsaun
jsaun
Flag of United States of America image

Put an insert/update trigger on the columns you are watching.  If the value gets entered (or attempted to be entered), then take the appropriate action.
Avatar of Roberto Madro R.

ASKER

The first part (creating the trigger) is easy, I'm looking for a method that, when the trigger is triggered that I get an email / alert or some other form of notification.
Avatar of Sean Stuber
Sean Stuber

Do you want it anytime someone attempts to put that value into your table, or only if they commit the change?
Anytime a specific value is entered.
I should have added "every time a value is committed "
that's tricky, because if I update a column to your magic value, I can have a trigger catch that and enqueue an email to be sent when you commit.

However, if I later update that column to some other value in the same transaction, that enqueued job won't know it shouldn't still send the email.

And what if I update the column to the magic value, and then you update it to something else?
Your session will wait on mine while I have the row(s) locked.  As soon as I commit I release my lock and your update will then apply immediately.  The email would still be sent but if you commit it won't be seen.


So, tracking committed values seems like it makes the most sense, but it's actually the hardest to track and potentially least reliable, unless you do periodic polling.   Because then you know the value has been committed and nobody has overwritten it yet.  Of course, as soon as you send the email, somebody could come along and update it, but there's no way to avoid that race condition.
I'll explain;

This is meant for an audit table that audits backend jobs, the column "SuccessfullyCompleted" of that table accepts the value "Y" or "N", if a job fails, I get a "N", else it's always "Y", if it's "N",  I'll examine that failed job and flip that value back to "Y" manually indicating that the issue has been addressed, so to answer your question, every single value in that table / column is "Y", except when there's an error.

I hope this helps.
Thx
I question the wisdom of depending on an e-mail notification to advise you of a database event.  An e-mail message like this may help in some cases, but as others have pointed out, there are some problems with this approach.  I prefer to use a report (or query) that can be run on demand to check for any/all possible problems that meet the criteria you are interested in.

And, for a "flag" column like this in an Oracle table to indicate success or failure, I much prefer using a null to indicate success, and a non-null value (or values) to indicate: not started, in-process, error, etc.  This allows an index to be set up on this "flag" column that will help you very efficiently find the few exceptions (that have a non-null value) and the index will stay small even if the total number of records in the table is large, when most of them are expected to have the "success" value in this column.  This assumes that new records will have a non-null value in this column, and your process will update this "flag" column to null when the process finishes successfully (you likely have an update of this column at that point in time anyway).

I admit that a Y/N column sounds more intuitive.  But, using a null to indicate success and a non-null to indicate a problem when we expect most records to have the "success" value, is a way to take advantage of the way Oracle indexes work.  This helps you find the exceptions efficiently, without wasting index space to store all of the "success" values, since a single index value that is shared by the majority of records in a table, is not a good use of index space.
I got what I got, it's a proprietary / third-party system, and I'm managing things from the outside,  I can create a trigger or a scheduled sql statement to fetch out the "N" records, but I need a way to send an email / alert to people.
If it is a proprietary / third-party system, then you are probably going to violate the entire support agreement by creating a trigger! Triggers, especially unexpected ones, can be a disaster when upgrading for example.

Strongly recommend you do use a scheduled sql statement to fetch out the "N" records.
Well, I need to email / notify people, any thoughts on that?
ASKER CERTIFIED SOLUTION
Avatar of Sean Stuber
Sean Stuber

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
The solution was adopted but not fully implemented yet (too many other moving pieces), will revisit if there's any issue.

Many Thanks.