Received: from vaccine.rki.de (firewall-user@vaccine.rki.de [193.175.81.250]) by hub.org (8.10.1/8.10.1) with SMTP id e7PB76593719 for ; Fri, 25 Aug 2000 07:07:07 -0400 (EDT) Received: by vaccine.rki.de; id NAA06794; Fri, 25 Aug 2000 13:06:57 +0200 Received: from unknown(10.15.130.13) by vaccine.rki.de via smap (V5.5) id xma006790; Fri, 25 Aug 00 13:06:18 +0200 Received: from wr-linux02.rki.de ([10.15.140.59]) by mailnu01.rki.de with SMTP (Microsoft Exchange Internet Mail Service Version 5.5.2650.21) id QD4NBV48; Fri, 25 Aug 2000 13:05:14 +0200 Date: Fri, 25 Aug 2000 13:06:07 +0200 (CEST) From: Andreas Tille cc: PostgreSQL SQL Subject: Re: Date of creation and of change In-Reply-To: <39A3E145.55A6F495@lexbase.net> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Archive-Number: 200008/276 On Wed, 23 Aug 2000, hlefebvre wrote: > Yes. The keywords NEW / OLD are available only in triggers > see > http://www.postgresql.org/users-lounge/docs/7.0/user/c40874113.htm#AEN4286 Well, I believe that, but CREATE FUNCTION changed_at_timestamp() RETURNS OPAQUE AS ' BEGIN ChangedAt := timestamp(''now''); RETURN NEW; END; ' LANGUAGE 'plpgsql'; CREATE TABLE WebSeite ( IdWebSeite int4 DEFAULT nextval('seqwebseite'::text) NOT NULL, CreatedAt timestamp DEFAULT now(), changedat timestamp DEFAULT now(), ... ); CREATE TABLE Menu ( IdMenu int4 DEFAULT nextval('seqmenu'::text) NOT NULL, CreatedAt timestamp DEFAULT now(), ChangedAt timestamp DEFAULT now(), ... ); CREATE TABLE MenuItem ( IdMenu int4 DEFAULT nextval('seqmenu'::text) NOT NULL, CreatedAt timestamp DEFAULT now(), ChangedAt timestamp DEFAULT now(), ... ); CREATE TRIGGER webseite_changed_at_timestamp BEFORE INSERT OR UPDATE ON WebSeite FOR EACH ROW EXECUTE PROCEDURE changed_at_timestamp(); CREATE TRIGGER menu_changed_at_timestamp BEFORE INSERT OR UPDATE ON Menu FOR EACH ROW EXECUTE PROCEDURE changed_at_timestamp(); CREATE TRIGGER menuitem_changed_at_timestamp BEFORE INSERT OR UPDATE ON MenuItem FOR EACH ROW EXECUTE PROCEDURE changed_at_timestamp(); web=# insert into menu (IdMenu, ...) values (3, ... ); ERROR: parser: parse error at or near "changedat" What's the problem here. Is there a conflict between the definition with DEFAULT now() and the TRIGGER BEFORE INSERT OR UPDATE. Should perhaps be the DEFAULT in the definition be removed or just the INSERT in the TRIGGER? Or is there a completely different problem? Kind regards Andreas.