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 49811D8244 for ; Wed, 12 Oct 2005 22:44:53 -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 67962-01 for ; Thu, 13 Oct 2005 01:44:49 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id 446E8D823B for ; Wed, 12 Oct 2005 22:44:51 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j9D1inQM016306; Wed, 12 Oct 2005 21:44:49 -0400 (EDT) To: Jeff Williams Cc: pgsql-sql@postgresql.org Subject: Re: Update timestamp on update In-reply-to: <434DB482.1000205@globaldial.com> References: <434DB482.1000205@globaldial.com> Comments: In-reply-to Jeff Williams message dated "Thu, 13 Oct 2005 09:12:34 +0800" Date: Wed, 12 Oct 2005 21:44:49 -0400 Message-ID: <16305.1129167889@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.006 required=5 tests=[AWL=0.006] X-Spam-Level: X-Archive-Number: 200510/117 X-Sequence-Number: 22970 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 regards, tom lane