Re: plpgsql and triggers - Mailing list pgsql-sql

From Michael Fuhr
Subject Re: plpgsql and triggers
Date
Msg-id 20050606023048.GA92417@winnie.fuhr.org
Whole thread Raw
In response to plpgsql and triggers  ("Bart Degryse" <Bart.Degryse@indicator.be>)
List 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/


pgsql-sql by date:

Previous
From: "Ramakrishnan Muralidharan"
Date:
Subject: Re: Multiple SRF parameters from query
Next
From: KÖPFERL Robert
Date:
Subject: Re: How do write a query...