Re: 7.2.1 PL/pgSQL issue - Mailing list pgsql-general

From Stephan Szabo
Subject Re: 7.2.1 PL/pgSQL issue
Date
Msg-id 20020412000638.B54610-100000@megazone23.bigpanda.com
Whole thread Raw
In response to 7.2.1 PL/pgSQL issue  (Ed Loehr <pggeneral@bluepolka.net>)
List pgsql-general
On Fri, 12 Apr 2002, Ed Loehr wrote:

> This looks like a bug.  Only question is whose.  The triggered update of a
> timestamp field is not working.  I can see the expected outputs in the log,
> but the timestamp update is not sticking.  Can someone identify my error or
> test this on 7.2.1 and tell me if the bug is mine (most likely) or a bug in
> PL/pgSQL?
>
> -- Simple function to update the 'updated' column to the current time
> CREATE FUNCTION set_update_time() RETURNS OPAQUE AS
> 'BEGIN
>      NEW.updated := ''now'';
>      RAISE NOTICE ''Resetting %.updated to %'', TG_RELNAME, NEW.updated;
>      RETURN NEW;
> END;'
> LANGUAGE 'plpgsql';
>
> CREATE TABLE plpgsql_test (
>      id      SERIAL,
>      created TIMESTAMP NOT NULL DEFAULT now(),
>      updated TIMESTAMP NOT NULL DEFAULT now()
> );
>
> CREATE TRIGGER plpgsql_test_trigger
>     AFTER UPDATE ON plpgsql_test FOR EACH ROW
>     EXECUTE PROCEDURE set_update_time();

I think you want a before update trigger since you're
modifying NEW.



pgsql-general by date:

Previous
From: Markus Wagner
Date:
Subject: how to get more detailed error messages?
Next
From: "PGMailList"
Date:
Subject: Re: 7.2.1 PL/pgSQL issue