Welcome to the dBforums forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions, articles and access our other FREE features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload your own photos and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact contact support.

If you prefer not to see double-underlined words and corresponding ads, place your cursor
here for ContentLink opt out.

Go Back  dBforums > Database Server Software > Oracle > Mail and Oracle

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 04-23-03, 09:01
cecodeel cecodeel is offline
Registered User
 
Join Date: Nov 2002
Location: Holland
Posts: 11
Mail and Oracle

Hi,

I am using Oracle 8.1.7 on a Windows 2000 Server.
I want to generate an E-mail when a specific table is updated.
Can someone tell me what the best way is to do this ?

Thanks.

Cecodeel
Reply With Quote
  #2 (permalink)  
Old 04-23-03, 09:11
andrewst andrewst is offline
Moderator.
 
Join Date: Sep 2002
Location: UK
Posts: 4,874
Re: Mail and Oracle

Quote:
Originally posted by cecodeel
Hi,

I am using Oracle 8.1.7 on a Windows 2000 Server.
I want to generate an E-mail when a specific table is updated.
Can someone tell me what the best way is to do this ?

Thanks.

Cecodeel

Create an AFTER UPDATE trigger on the table. Use the UTL_SMTP package to send the email. However, there are 2 issues with this:
1) UTL_SMTP is pretty slow, which will impact your performance
2) UTL_SMTP will send out the email even if the update is rolled back.

These issues can be overcome by using DBMS_JOB as follows:
- Create a stored procedure that uses UTL_SMTP to send an email
- In the trigger, call DBMS_JOB.SUBMIT to immediately run your stored procedure

This overcomes the above issues because:
1) The job is run asynchronously, so the trigger does not have to wait for the job to complete
2) The job only runs when the update is committed, and not at all if it is rolled back.

If you have Tom Kyte's book "Expert One On One Oracle", he shows a complete implementation of this approach.
__________________
Tony Andrews
http://tonyandrews.blogspot.com
Reply With Quote
  #3 (permalink)  
Old 04-23-03, 10:23
cecodeel cecodeel is offline
Registered User
 
Join Date: Nov 2002
Location: Holland
Posts: 11
Re: Mail and Oracle

Quote:
Originally posted by andrewst
Create an AFTER UPDATE trigger on the table. Use the UTL_SMTP package to send the email. However, there are 2 issues with this:
1) UTL_SMTP is pretty slow, which will impact your performance
2) UTL_SMTP will send out the email even if the update is rolled back.

These issues can be overcome by using DBMS_JOB as follows:
- Create a stored procedure that uses UTL_SMTP to send an email
- In the trigger, call DBMS_JOB.SUBMIT to immediately run your stored procedure

This overcomes the above issues because:
1) The job is run asynchronously, so the trigger does not have to wait for the job to complete
2) The job only runs when the update is committed, and not at all if it is rolled back.

If you have Tom Kyte's book "Expert One On One Oracle", he shows a complete implementation of this approach.



Ok
Thanks

Cecodeel
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On