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 434779FB2C8 for ; Mon, 31 Jul 2006 13:13:10 -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 03043-09 for ; Mon, 31 Jul 2006 13:13:01 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey- Received: from ciao.gmane.org (main.gmane.org [80.91.229.2]) by postgresql.org (Postfix) with ESMTP id 6131E9FA2D5 for ; Mon, 31 Jul 2006 13:12:59 -0300 (ADT) Received: from list by ciao.gmane.org with local (Exim 4.43) id 1G7aNm-0008Rj-7H for pgsql-sql@postgresql.org; Mon, 31 Jul 2006 18:12:42 +0200 Received: from pirus.securax.be ([213.16.46.130]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 31 Jul 2006 18:12:42 +0200 Received: from milen by pirus.securax.be with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 31 Jul 2006 18:12:42 +0200 X-Injected-Via-Gmane: http://gmane.org/ To: pgsql-sql@postgresql.org From: "Milen A. Radev" Subject: Re: Triggers using PL/pgSQL Date: Mon, 31 Jul 2006 19:12:30 +0300 Lines: 15 Message-ID: <44CE2BEE.2070201@radev.net> References: <20060731041644.32247.qmail@web56610.mail.re3.yahoo.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Complaints-To: usenet@sea.gmane.org X-Gmane-NNTP-Posting-Host: pirus.securax.be User-Agent: Mozilla Thunderbird 1.5.0.5 (Windows/20060719) In-Reply-To: <20060731041644.32247.qmail@web56610.mail.re3.yahoo.com> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200607/381 X-Sequence-Number: 25955 Thusitha Kodikara написа: > 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? http://www.postgresql.org/docs/8.1/static/plpgsql-trigger.html -- Milen A. Radev