From: Tom Lane <tgl@sss.pgh.pa.us>
To: Oscar Serrano <oserra@fondos.net>
Cc: pgsql-interfaces@postgreSQL.org <pgsql-interfaces@postgresql.org>
Subject: Re: a trigger that sends an email
Date: Thu, 06 Apr 2000 10:51:06 -0400
Message-ID: <26948.955032666@sss.pgh.pa.us> (raw)
In-Reply-To: <NDBBKNFDELOHICEHIMGGMELGCCAA.oserra@fondos.net>
References: <NDBBKNFDELOHICEHIMGGMELGCCAA.oserra@fondos.net>
"Oscar Serrano" <oserra@fondos.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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-interfaces@postgresql.org
Cc: tgl@sss.pgh.pa.us, oserra@fondos.net
Subject: Re: a trigger that sends an email
In-Reply-To: <26948.955032666@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox