pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Louis-David Mitterrand <vindex+lists-pgsql-sql@apartia.org>
To: pgsql-sql@postgresql.org
Subject: Re: dynmic column names inside trigger?
Date: Thu, 22 Nov 2007 14:54:04 +0100
Message-ID: <20071122135403.GA10426@apartia.fr> (raw)
In-Reply-To: <4743F6E5.A3DD.0030.0@indicator.be>
References: <20071120161258.GA27106@apartia.fr>
	<4743F6E5.A3DD.0030.0@indicator.be>

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,



view thread (9+ messages)  latest in thread

Message-ID: <20071122135403.GA10426@apartia.fr>
Permalink:  ../20071122135403.GA10426@apartia.fr/
Also on:    postgresql.org/message-id/20071122135403.GA10426@apartia.fr

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: vindex+lists-pgsql-sql@apartia.org
  Subject: Re: dynmic column names inside trigger?
  In-Reply-To: <20071122135403.GA10426@apartia.fr>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox