Path: newssvr20.news.prodigy.com!newsmst01.news.prodigy.com!prodigy.com!news-FFM2.ecrc.net!newsfeed.vmunix.org!feed.news.nacamar.de!news.belwue.de!not-for-mail
From: Holger Baer <holger.baer@science-computing.de>
Newsgroups: comp.databases.oracle.server
Subject: Re: sending an email from a table trigger (before inserting row)
Date: Mon, 07 Jul 2003 14:01:31 +0200
Organization: InterNetNews at News.BelWue.DE (Stuttgart, Germany)
Lines: 48
Message-ID: <3F09611B.1030209@science-computing.de>
References: <be0irt$9b1$1@unbe.sarenet.es> <1a75df45.0307030425.febba27@posting.google.com> <MPG.196e4518bab3169398978d@news.cis.dfn.de> <1a75df45.0307062152.145a6bbd@posting.google.com> <MPG.1973669b2e93eb88989795@news.cis.dfn.de>
NNTP-Posting-Host: blackhole.science-computing.de
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit
X-Trace: news.BelWue.DE 1057579292 7662 193.197.16.3 (7 Jul 2003 12:01:32 GMT)
X-Complaints-To: news@news.belwue.de
NNTP-Posting-Date: Mon, 7 Jul 2003 12:01:32 +0000 (UTC)
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.0.1) Gecko/20020911
X-Accept-Language: en-us, en
Xref: newssvr20.news.prodigy.com comp.databases.oracle.server:237047

Jeremy wrote:
> In article <1a75df45.0307062152.145a6bbd@posting.google.com>, 
> vslabs@onwe.co.za says...
> 
>>Jeremy <newspostings@hazelweb.co.uk> wrote 
>>
>>
>>>I don't think Jon was necessarily saying that the trigger was going to 
>>>do validation per se - perhaps just that under certain data conditions, 
>>>he would like to be able to send an e-mail based on an update to a 
>>>table. If you read it that way, do you have the same opinion?
>>
> 
> <SNIP>
> 
>>Know what we are at the end of the day Jeremy? Problem solvers. From
>>DBA's to developers. What determines the difference between good and
>>bad problem solvers? How well and to what extent a problem is solved.
>>You want to tell me that that a crude method like send mail in a
>>trigger can truly solve the problem, never mind  that it will be
>>introducing a whole bunch of other problems?
> 
> 
> Hmm... interesting pov. I guess I just didn't see anything fundamentally 
> wrong with the concept of sending e-mail from within a trigger - agree 
> that if talking directly to the smtp server it is definitely a no-no, 
> but as a means of creating a 'request' processed separately by a 
> procedure under DBMS_JOB? Do you say that you should never initiate (by 
> which I mean log a request for later processing) an email from within a 
> DB trigger?
> 
> 

Well, I think it depends on what you mean by 'initiate'. If you use dbms_job
to schedule the mail to be sent later, you've initiated the mail and there
is nothing fundamentally wrong with that.

But of course, you should not directly talk to the smtp server from the trigger.
It just adds a large overhead to the trigger, which will not only greatly reduce
the possible throughput, but also you loose the transactional consistency:
If you send the mail through the db trigger, that mail is going to be sent
no matter if the transaction succeeds or is rolled back. By using dbms_job,
the mail is only sent if the transaction is committed.

My (not exactly my but derived from Tom Kytes book "expert one-on-one") 2c

Holger

