Received: from sss2.sss.pgh.pa.us (sss.pgh.pa.us [209.114.166.2]) by hub.org (8.9.3/8.9.3) with ESMTP id KAA82085 for ; Thu, 6 Apr 2000 10:51:23 -0400 (EDT) (envelope-from tgl@sss.pgh.pa.us) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss2.sss.pgh.pa.us (8.9.3/8.9.3) with ESMTP id KAA26951; Thu, 6 Apr 2000 10:51:07 -0400 (EDT) To: "Oscar Serrano" cc: "pgsql-interfaces@postgreSQL.org" Subject: Re: a trigger that sends an email In-reply-to: References: Comments: In-reply-to "Oscar Serrano" message dated "Thu, 06 Apr 2000 13:23:57 +0200" Date: Thu, 06 Apr 2000 10:51:06 -0400 Message-ID: <26948.955032666@sss.pgh.pa.us> From: Tom Lane X-Archive-Number: 200004/40 "Oscar Serrano" 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