Received: from localhost (unknown [200.46.204.184]) by postgresql.org (Postfix) with ESMTP id 0ADA52E004E for ; Thu, 22 Nov 2007 09:54:14 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.184]) (amavisd-maia, port 10024) with ESMTP id 60052-03 for ; Thu, 22 Nov 2007 09:54:03 -0400 (AST) Received: from sargon.lncsa.com (sargon.lncsa.com [212.99.8.251]) by postgresql.org (Postfix) with ESMTP id BE2122E006F for ; Thu, 22 Nov 2007 09:54:07 -0400 (AST) Received: from localhost (localhost.localdomain [127.0.0.1]) by sargon.lncsa.com (Postfix) with ESMTP id 719703015E2C for ; Thu, 22 Nov 2007 14:54:05 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at lncsa.com Received: from sargon.lncsa.com ([127.0.0.1]) by localhost (sargon.lncsa.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id MB29XmLPGrVD for ; Thu, 22 Nov 2007 14:54:05 +0100 (CET) Received: from zenon.apartia.fr (zenon.apartia.fr [10.0.3.1]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "zenon.apartia.fr", Issuer "ca.apartia.fr" (verified OK)) by sargon.lncsa.com (Postfix) with ESMTP id 4C8F33013BA0 for ; Thu, 22 Nov 2007 14:54:05 +0100 (CET) Received: from trajan.apartia.fr (trajan.apartia.fr [10.0.3.121]) by zenon.apartia.fr (Postfix) with ESMTP id 59B5059C5000C for ; Thu, 22 Nov 2007 14:54:04 +0100 (CET) Received: by trajan.apartia.fr (Postfix, from userid 1000) id 34942256ED73; Thu, 22 Nov 2007 14:54:04 +0100 (CET) Date: Thu, 22 Nov 2007 14:54:04 +0100 From: Louis-David Mitterrand To: pgsql-sql@postgresql.org Subject: Re: dynmic column names inside trigger? Message-ID: <20071122135403.GA10426@apartia.fr> Mail-Followup-To: pgsql-sql@postgresql.org References: <20071120161258.GA27106@apartia.fr> <4743F6E5.A3DD.0030.0@indicator.be> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4743F6E5.A3DD.0030.0@indicator.be> User-Agent: Mutt/1.5.17 (2007-11-01) X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200711/116 X-Sequence-Number: 29644 On Wed, Nov 21, 2007 at 09:14:14AM +0100, Bart Degryse wrote: > I would do something like this (not tested, but conceptually working): Hello, > BEGIN > if old.story is not null and new.story != old.story then > new.story = sanitize_text(new.story); > end if; > --checks on other field can be included here, eg > if old.otherfield is not null and new.otherfield != old.otherfield then > new.otherfield = sanitize_text(new.otherfield); > end if; But if I test a non-existent column for not being null I will have an exception, no? Otherwise this is a nice way of doing it. Thanks,