X-Original-To: pgsql-sql-postgresql.org@postgresql.org Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id 58B5C9FB336 for ; Mon, 31 Jul 2006 13:02:20 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 01816-05 for ; Mon, 31 Jul 2006 13:02:02 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from alnrmhc11.comcast.net (alnrmhc13.comcast.net [204.127.225.93]) by postgresql.org (Postfix) with ESMTP id 28F3E9FB36A for ; Mon, 31 Jul 2006 13:01:39 -0300 (ADT) Received: from [10.0.1.4] (c-71-236-202-17.hsd1.or.comcast.net[71.236.202.17]) by comcast.net (alnrmhc13) with SMTP id <20060731154751b1300iectqe>; Mon, 31 Jul 2006 15:47:51 +0000 Subject: Re: Triggers using PL/pgSQL From: Ken Hill Reply-To: ken@scottshill.com To: Thusitha Kodikara Cc: pgsql-sql@postgresql.org In-Reply-To: <20060731041644.32247.qmail@web56610.mail.re3.yahoo.com> References: <20060731041644.32247.qmail@web56610.mail.re3.yahoo.com> Content-Type: text/plain Organization: Scotts Hill Associates, Inc. Date: Mon, 31 Jul 2006 08:47:50 -0700 Message-Id: <1154360871.11723.2.camel@ken-laptop> Mime-Version: 1.0 X-Mailer: Evolution 2.6.1 Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=3.816 tagged_above=0 required=5 tests=SPF_HELO_SOFTFAIL, SPF_SOFTFAIL X-Spam-Level: *** X-Archive-Number: 200607/380 X-Sequence-Number: 25954 On Sun, 2006-07-30 at 21:16 -0700, Thusitha Kodikara wrote: > Hello, > > I am interested in developing some triggers to keep track of records > that are changed (possibly the changes of one or more specific > columns). In addition to keeping the new values, I also need to keep > the old values (may be on a separate table). > > Though I have done similar things in other RDBMs using SQL, I find > doing this in Postgres, a little bit complicated - may be because it > needs to be done through a separate procedural language and through a > separate function. The Postgres documentation also didn't provide much > help ( the examples in C). I was mainly looking for example showing > how to refer 'OLD' and 'NEW' rows using PL/pgSQL. > > Can someone please direct me to some such examples? > > Thanks and regards, > -Thusitha I too am very interested in this! -Ken