Re: plpgsql and triggers

From: Michael Fuhr <mike(at)fuhr(dot)org>
To: Bart Degryse <Bart(dot)Degryse(at)indicator(dot)be>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: plpgsql and triggers
Date: 2005-06-06 02:30:48
Message-ID: 20050606023048.GA92417@winnie.fuhr.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

On Thu, Jun 02, 2005 at 01:57:26PM +0200, Bart Degryse wrote:
>
> I'm looking for a way to use a parameter given to a trigger function as
> fieldname. It should be something like
> create function f_makeupper() returns trigger as '
> begin
> NEW.TG_ARGV[0] := upper(NEW.TG_ARGV[0]);
> RETURN NEW;
> end;
> ' language 'plpgsql';

As you've discovered, this doesn't work in PL/pgSQL: the above code
references the new row's TG_ARGV column, which doesn't exist. This
comes up frequently; see the list archives for past discussion. The
usual advice is to use a language like PL/Perl, PL/Tcl, PL/Python, etc.
that provides this capability.

--
Michael Fuhr
http://www.fuhr.org/~mfuhr/

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message KÖPFERL Robert 2005-06-06 10:06:01 Re: How do write a query...
Previous Message Michael Fuhr 2005-06-05 00:52:24 Re: Multiple SRF parameters from query