Re: Referencing any field in a trigger - Mailing list pgsql-general

From Robert Fitzpatrick
Subject Re: Referencing any field in a trigger
Date
Msg-id 1180114300.15450.54.camel@columbus.webtent.org
Whole thread Raw
In response to Re: Referencing any field in a trigger  (Alvaro Herrera <alvherre@commandprompt.com>)
Responses Re: Referencing any field in a trigger
List pgsql-general
On Fri, 2007-05-25 at 12:00 -0400, Alvaro Herrera wrote:
> Robert Fitzpatrick wrote:
> > How can I reference any NEW field in an insert/update trigger function?
> > When someone inserts or updates any field with a single asterisk (*), I
> > need it to become '%%%'. But if they use an asterisk in any combination
> > with other fields, then I want to TRANSLATE those asterisks to a single
> > '%'.
>
> You can't do that with PL/pgSQL.  You can with other languages like
> PL/Perl though (which has better tools for string treatment, so it is a
> good idea anyway).

Great! I use Perl for a lot of string functions now, but I've never used
pl/perl for triggers. I did not know I could use pl/perl in
triggers...but do now :)

http://www.postgresql.org/docs/8.0/static/plperl-triggers.html

But still, how would I reference all fields using the pl/perl? Can I
specify column numbers versus names as in '$_TD->{new}{1}' for the first
column and loop or something? For instance, I would like to be able to
say if any NEW column has a single asterisk only, set it to '%%%'.

--
Robert


pgsql-general by date:

Previous
From: Andrew Sullivan
Date:
Subject: Re: why postgresql over other RDBMS
Next
From: Alvaro Herrera
Date:
Subject: Re: Referencing any field in a trigger