X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 7D66D52834 for ; Thu, 9 Jun 2005 17:02:47 -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 10582-03 for ; Thu, 9 Jun 2005 20:02:42 +0000 (GMT) Received: from mr2.surnet.cl (smtp2.surnet.cl [216.155.73.163]) by svr1.postgresql.org (Postfix) with ESMTP id 34AA952825 for ; Thu, 9 Jun 2005 17:02:41 -0300 (ADT) Received: from smtp2.surnet.cl (216.155.73.169) by mr2.surnet.cl (7.0.031.3) id 4259ADFA00D4D6F1; Thu, 9 Jun 2005 16:02:54 -0400 Received: from smtp2.surnet.cl (mr2.surnet.cl []) by mr2.surnet.cl ([216.155.73.169]); Thu, 09 Jun 2005 20:02:54 +0000 Received: from cluster.surnet.cl (216.155.73.164) by smtp2.surnet.cl (7.0.031.3) id 4259ADE3007E6AE1; Thu, 9 Jun 2005 16:02:54 -0400 Received: from localhost (200.85.216.119) by cluster.surnet.cl (7.0.024) id 4276578F005523A6; Thu, 9 Jun 2005 16:02:42 -0400 Received: by localhost (Postfix, from userid 1000) id 95911C2DC08; Thu, 9 Jun 2005 16:03:15 -0400 (CLT) Date: Thu, 9 Jun 2005 16:03:15 -0400 From: Alvaro Herrera To: Chris Hoover Cc: pgsql-admin@postgresql.org Subject: Re: Help with function Message-ID: <20050609200315.GH12706@surnet.cl> References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.9i X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=1.586 tagged_above=0 required=5 tests=AWL, DNS_FROM_RFC_ABUSE, DNS_FROM_RFC_POST, FORGED_RCVD_HELO X-Spam-Level: * X-Archive-Number: 200506/62 X-Sequence-Number: 17817 On Thu, Jun 09, 2005 at 06:17:24PM +0000, Chris Hoover wrote: > I am trying to write a very generic function to be used for table auditing. I am kind of stuck on how to make the function use the column names I pull from the db. Is there anyway to do what I have below? My main concern is this segment: > > if (new.columnName != old.columnName or > (old.columnName is null and new.columnName is not null) or > (old.columnName is not null and new.columnName is null) > ) then > > How can I get PostgreSQL to substitute the selected column name for the old.columnName/new.columnName? Standard answer has been "can't do that in plpgsql". You may want to try pl/perl, pl/python (does that support triggers?) or pl/tcl. If performance is an issue, write the function in C. -- Alvaro Herrera () "If it wasn't for my companion, I believe I'd be having the time of my life" (John Dunbar)