X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id A139DD1CE23 for ; Sat, 23 Aug 2003 01:53:59 -0300 (ADT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 83906-10 for ; Sat, 23 Aug 2003 01:53:49 -0300 (ADT) Received: from megazone.bigpanda.com (45.mufb.snfc.sffca01r18.dsl.att.net [12.103.249.45]) by svr1.postgresql.org (Postfix) with ESMTP id 955FAD1D114 for ; Sat, 23 Aug 2003 01:53:48 -0300 (ADT) Received: by megazone.bigpanda.com (Postfix, from userid 1001) id A2A23D5FA; Fri, 22 Aug 2003 21:53:48 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by megazone.bigpanda.com (Postfix) with ESMTP id 9854B5C0D; Fri, 22 Aug 2003 21:53:48 -0700 (PDT) Date: Fri, 22 Aug 2003 21:53:48 -0700 (PDT) From: Stephan Szabo To: Stuart Cc: Subject: Re: Auto-update a field when record is changed In-Reply-To: <200308222332.47526.sfbarbee@yahoo.com> Message-ID: <20030822215217.L6822-100000@megazone.bigpanda.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200308/284 X-Sequence-Number: 14900 On Fri, 22 Aug 2003, Stuart wrote: > Folks, > > I was wandering if there was a feasible way to automatically update a field > in a table, say 'revision_date' in a record whenever any other field in the > record is changed. My attempts to use a trigger caused repeating loops and > bombed with error. I would like to be able to update such a field > automatically anytime a record was updated. Any help would be appreciated. That seems like a job for a before trigger and changing the to be update/inerted record before the action occurs in general. Don't use an update statement but change the record variables given as the NEW row.