X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 4ECDB565AD for ; Thu, 10 Mar 2005 20:21:42 +0000 (GMT) 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 48787-04 for ; Thu, 10 Mar 2005 20:21:37 +0000 (GMT) Received: from lerami.lerctr.org (lerami.lerctr.org [192.147.25.11]) by svr1.postgresql.org (Postfix) with ESMTP id AFC625659F for ; Thu, 10 Mar 2005 20:21:36 +0000 (GMT) Received: from lerlaptop.lerctr.org ([192.147.25.14]) by lerami.lerctr.org with esmtpsa (TLSv1:RC4-MD5:128) (Exim 4.50) id 1D9UA3-0001MS-Jo; Thu, 10 Mar 2005 14:21:36 -0600 From: Larry Rosenman Organization: LERCTR Consulting To: Henry Ortega Subject: Re: best way to auto-update a field when row is updated Date: Thu, 10 Mar 2005 14:21:33 -0600 User-Agent: KMail/1.7.1 Cc: pgsql-sql@postgresql.org References: <2bffcc3305031012092fde7dc2@mail.gmail.com> In-Reply-To: <2bffcc3305031012092fde7dc2@mail.gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200503101421.33958.ler@lerctr.org> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.004 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200503/157 X-Sequence-Number: 20636 On Thursday 10 March 2005 02:09 pm, Henry Ortega wrote: > I have the following table > > FIELD_A | FIELD_B | TSTAMP > --------------------------------------------------------------------------- >----------------------------- x y > 2005-03-10 14:56:47.456431 > > TSTAMP = not null default now() > > What's the best way to always auto-update TSTAMP to it's > default value whenever the row gets updated? > (e.g. update TABLENAME set FIELD_A='zzz' where FIELD_A='x'; > should automatically set TSTAMP to now) > trigger on update/insert. > ---------------------------(end of broadcast)--------------------------- > TIP 5: Have you checked our extensive FAQ? > > http://www.postgresql.org/docs/faq -- Larry Rosenman http://www.lerctr.org/~ler Phone: +1 214-351-4152 E-Mail: ler@lerctr.org US Mail: 3535 Gaspar Drive, Dallas, TX 75220-3611