X-Original-To: pgsql-sql@postgresql.org Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 95310476286 for ; Wed, 5 Feb 2003 10:50:44 -0500 (EST) Received: from matrix.gatewaynet.com (unknown [217.19.69.50]) by postgresql.org (Postfix) with ESMTP id BF800476555 for ; Wed, 5 Feb 2003 10:42:51 -0500 (EST) Received: from matrix.gatewaynet.com (matrix.gatewaynet.com [217.19.69.50] (may be forged)) by matrix.gatewaynet.com (8.12.5/8.12.5) with ESMTP id h15JmVX0007918; Wed, 5 Feb 2003 17:48:31 -0200 Received: from localhost (achill@localhost) by matrix.gatewaynet.com (8.12.5/8.12.5/Submit) with ESMTP id h15JmUFI007914; Wed, 5 Feb 2003 17:48:31 -0200 Date: Wed, 5 Feb 2003 17:48:30 -0200 (GMT+2) From: Achilleus Mantzios To: Neal Lindsay Cc: pgsql-sql@postgresql.org Subject: Re: automatic time/user stamp - rule or trigger? In-Reply-To: Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200302/98 X-Sequence-Number: 11496 On Wed, 5 Feb 2003, Neal Lindsay wrote: > 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. You may want to use rules if you need rewriting. What you actually need is some sort of driver to a specific table. You could create a view to that table (to hide the accounting columns), and then create rules on that view that do the job as you wish. > > Thanks, > -Neal > > > ---------------------------(end of broadcast)--------------------------- > TIP 4: Don't 'kill -9' the postmaster > ================================================================== Achilleus Mantzios S/W Engineer IT dept Dynacom Tankers Mngmt Nikis 4, Glyfada Athens 16610 Greece tel: +30-10-8981112 fax: +30-10-8981877 email: achill@matrix.gatewaynet.com mantzios@softlab.ece.ntua.gr