Re: Postgres Triggers issue

From: "Igor Neyman" <ineyman(at)perceptron(dot)com>
To: <u235sentinel(at)gmail(dot)com>, <pgsql-general(at)postgresql(dot)org>
Subject: Re: Postgres Triggers issue
Date: 2010-02-11 16:51:21
Message-ID: F4C27E77F7A33E4CA98C19A9DC6722A205886216@EXCHANGE.corp.perceptron.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


> -----Original Message-----
> From: u235sentinel [mailto:u235sentinel(at)gmail(dot)com]
> Sent: Wednesday, February 10, 2010 11:15 PM
> To: pgsql-general(at)postgresql(dot)org
> Subject: Postgres Triggers issue
>
> I have a strange problem we noticed the other day with
> triggers. We're running 8.3.3 on Solaris 10 (intel) and have
> a feed that comes in regularly to populate a table we're
> working on. The feed works just fine inserting rows however
> the following trigger stops the feed until we remove the
> trigger. Any thoughts on what I'm doing wrong here?
>
> Thanks!
>
> ---
>
> CREATE OR REPLACE FUNCTION r.m_t()
> RETURNS trigger AS
> $BODY$
> BEGIN
> INSERT INTO temp_m_t VALUES (NEW.*,1+1); RETURN NULL; END;
> $BODY$ LANGUAGE 'plpgsql';
>
>
> CREATE TRIGGER tafter
> AFTER INSERT OR UPDATE
> ON r.m_a
> FOR EACH ROW
> EXECUTE PROCEDURE r.m_t();
>
>

Trigger function for an insert/update trigger should return "NEW", not
NULL (OLD - for "on delete" trigger):

CREATE OR REPLACE FUNCTION r.m_t()
RETURNS trigger AS
$BODY$
BEGIN
INSERT INTO temp_m_t VALUES (NEW.*,1+1); RETURN NEW; END;
$BODY$ LANGUAGE 'plpgsql';

Igor Neyman

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Richard Huxton 2010-02-11 16:56:51 Re: Searching a DB index.. possible?
Previous Message Moe 2010-02-11 16:42:00 Re: Searching a DB index.. possible?