X-Original-To: pgsql-sql@postgresql.org Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id C16454758E1 for ; Wed, 5 Feb 2003 18:31:03 -0500 (EST) Received: from news.hub.org (news.hub.org [64.49.215.80]) by postgresql.org (Postfix) with ESMTP id 291E7474E4F for ; Wed, 5 Feb 2003 18:31:03 -0500 (EST) Received: by news.hub.org (Postfix, from userid 8) id 0D39A43A857; Wed, 5 Feb 2003 18:31:03 -0500 (EST) From: "codeWarrior" X-Newsgroups: comp.databases.postgresql.sql Subject: Re: automatic time/user stamp - rule or trigger? Date: Wed, 5 Feb 2003 15:38:52 -0800 Organization: Hub.Org Networking Services (http://www.hub.org) Lines: 31 Message-ID: References: Reply-To: "codeWarrior" X-Complaints-To: usenet@news.hub.org X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2600.0000 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000 To: pgsql-sql@postgresql.org X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200302/126 X-Sequence-Number: 11524 You're doing update right ??? Just update the column... It's even easier if, when you do your updates... You just: UPDATE blah SET field = value,...., updatestamp = 'Now()' WHERE condition... GP "Neal Lindsay" wrote in message news:b1r864$2mpp$1@news.hub.org... > I have a table that I want to keep track of the user who last modified > it and the timestamp of the modification. Should I use a trigger or a rule? > > CREATE TABLE stampedtable ( > stampedtableid SERIAL PRIMARY KEY, > updatestamp timestamp NOT NULL DEFAULT now(), > updateuser name NOT NULL DEFAULT current_user, > sometext text > ); > > I suspect that I want a rule, but all the examples in the documentation > seem to update a separate table and not override (or add) the > insert/update to the timestamp and name columns. > > Thanks, > -Neal >