Skip site navigation (1) Skip section navigation (2)

Re: a trigger that sends an email

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Oscar Serrano" <oserra(at)fondos(dot)net>
Cc: "pgsql-interfaces(at)postgreSQL(dot)org" <pgsql-interfaces(at)postgresql(dot)org>
Subject: Re: a trigger that sends an email
Date: 2000-04-06 14:51:06
Message-ID: 26948.955032666@sss.pgh.pa.us (view raw or flat)
Thread:
Lists: pgsql-interfaces
"Oscar Serrano" <oserra(at)fondos(dot)net> writes:
>>>> I thing I need to create a trigger. And I thing I need to create a
>>>> function that sends an email.
>>>> Is it possible?
>>>> May I do the function that sends the email in Perl?

I don't think you can do this directly from a trigger, unless you want
to add the mail-sending function as a C extension to the backend.
You'll run into security restrictions.  All of the higher-level trigger
programming languages we offer are "trusted", which means you can't do
anything that would affect files or programs outside the database.
Sending email is right out.

Of course there's nothing wrong with a C-coded function; the system's
full of them ;-).  But you might want to think about other ways.

One possibility is to set up an always-running application that connects
to the database and then just sits there waiting for records to be added
to the table, then sends the email when that happens.  You could use a
NOTIFY command (executed by a trigger on the table) to wake up the app
when something happens, so that it doesn't need to take up CPU time
checking the table unnecessarily.

			regards, tom lane

In response to

Responses

pgsql-interfaces by date

Next:From: RichardDate: 2000-04-06 15:29:44
Subject: Re: a trigger that sends an email + returning multiple records
Previous:From: The Hermit HackerDate: 2000-04-06 14:03:50
Subject: Ksql Interface ...

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group