Tables and functions and triggers oh my...

From: "Fontenot, Paul" <Paul(dot)Fontenot(at)bannerhealth(dot)com>
To: <pgsql-novice(at)postgresql(dot)org>
Subject: Tables and functions and triggers oh my...
Date: 2003-05-19 22:36:43
Message-ID: 230BCAB977308F43BD851AFAE55A86413D6CC6@phx01018.bannerhealth.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

I'm going nuts, when I have this table/function/trigger combo my table
never updates - works great as soon as I drop the trigger. Can someone
not so green in PostgreSQL take a gander and tell me what I've done
wrong?

CREATE TABLE syslogTB (
facility char(10),
priority char(10),
date date,
time time,
host varchar(128),
message text
);

create function PIXMail() returns opaque as '
DECLARE
logRec RECORD;
textMessage text;
BEGIN
select into logRec date,time,message from syslogtb where message
= NEW.message;
if logRec.message = NEW.message then
textMessage := ''The PIX has generated the following: ''
logRec.message '''';
perform pgmail(''PIX <some_email_addy>'',''Paul Fontenot
<some_email_addy>'',''PIX Message'', t
extMessage);
end if;
return NEW;
END;' language 'plpgsql';

CREATE TRIGGER trgPIXMail
BEFORE INSERT OR UPDATE ON syslogtb FOR EACH ROW
EXECUTE PROCEDURE pixmail();

***PRIVILEGED & CONFIDENTIAL***
Unless expressly stated otherwise, this message (and any attachment(s)
thereto) is confidential and may be privileged. It is intended for the
addressee(s) only. If you are not an addressee, any disclosure or
copying of the contents of this e-mail or any action taken (or not
taken) in reliance on it is strictly prohibited. If you are not an
addressee, please inform sender immediately and delete this message from
your system.

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Joe Conway 2003-05-20 04:27:29 Re: Tables and functions and triggers oh my...
Previous Message Josh Berkus 2003-05-19 21:44:00 Re: 7.2.1 => 7.3.2