X-Original-To: pgsql-sql@postgresql.org Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id B974B476492 for ; Wed, 5 Feb 2003 10:28:27 -0500 (EST) Received: from news.hub.org (news.hub.org [64.49.215.80]) by postgresql.org (Postfix) with ESMTP id C4200476D25 for ; Wed, 5 Feb 2003 09:47:33 -0500 (EST) Received: by news.hub.org (Postfix, from userid 8) id 74CDF43A94D; Wed, 5 Feb 2003 09:47:33 -0500 (EST) From: Neal Lindsay X-Newsgroups: comp.databases.postgresql.sql Subject: automatic time/user stamp - rule or trigger? Date: Wed, 05 Feb 2003 09:47:34 -0500 Organization: Hub.Org Networking Services (http://www.hub.org) Lines: 17 Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Complaints-To: usenet@news.hub.org User-Agent: Mozilla/5.0 (Windows; U; Win98; en-US; rv:1.2.1) Gecko/20021130 X-Accept-Language: en-us, en To: pgsql-sql@postgresql.org X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200302/96 X-Sequence-Number: 11494 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