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/