X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 2F6F9D8280 for ; Wed, 12 Oct 2005 23:42:06 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 80859-02 for ; Thu, 13 Oct 2005 02:42:01 +0000 (GMT) Received: from dagon.globaldial.com (dagon.globaldial.com [202.74.164.46]) by svr1.postgresql.org (Postfix) with ESMTP id A4AC1D824F for ; Wed, 12 Oct 2005 23:42:03 -0300 (ADT) Received: from [192.168.10.72] (satellite [203.24.54.17]) by dagon.globaldial.com (Postfix) with ESMTP id 46E6157441; Thu, 13 Oct 2005 10:42:08 +0800 (WST) Message-ID: <434DC97E.7000603@globaldial.com> Date: Thu, 13 Oct 2005 10:42:06 +0800 From: Jeff Williams User-Agent: Debian Thunderbird 1.0.7 (X11/20051001) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Tom Lane Cc: pgsql-sql@postgresql.org Subject: Re: Update timestamp on update References: <434DB482.1000205@globaldial.com> <16305.1129167889@sss.pgh.pa.us> In-Reply-To: <16305.1129167889@sss.pgh.pa.us> X-Enigmail-Version: 0.92.0.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0 required=5 tests=[none] X-Spam-Level: X-Archive-Number: 200510/121 X-Sequence-Number: 22974 Tom Lane wrote: >Jeff Williams writes: > > >> last_status_change timestamp DEFAULT now() >> >> > > > >>What I would like is that whenever the status is changed the >>last_status_change timestamp is updated to the current time. >> >> > >For this you use an ON UPDATE trigger; rules are not a good way to solve >it. See the documentation about triggers. The first example on this >page does it along with a few other things: >http://developer.postgresql.org/docs/postgres/plpgsql-trigger.html > > Thanks. Triggers was my first thought, but chapter 35 on Triggers didn't really indicate a way I could do this easily and scared me with a lot of c code. Maybe it is a good idea to present some of the more common things you would want to do with triggers in the triggers chapter? Jeff