Re: dynmic column names inside trigger?

From: Louis-David Mitterrand <vindex+lists-pgsql-sql(at)apartia(dot)org>
To: pgsql-sql(at)postgresql(dot)org
Subject: Re: dynmic column names inside trigger?
Date: 2007-11-22 13:54:04
Message-ID: 20071122135403.GA10426@apartia.fr
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

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,

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Louis-David Mitterrand 2007-11-22 13:54:59 Re: dynmic column names inside trigger?
Previous Message D'Arcy J.M. Cain 2007-11-22 13:48:54 Re: How to have a unique primary key on two tables