From: | Robert Fitzpatrick <lists(at)webtent(dot)net> |
---|---|
To: | PostgreSQL <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: Referencing any field in a trigger |
Date: | 2007-05-25 17:31:40 |
Message-ID: | 1180114300.15450.54.camel@columbus.webtent.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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
From | Date | Subject | |
---|---|---|---|
Next Message | Alvaro Herrera | 2007-05-25 17:45:20 | Re: Referencing any field in a trigger |
Previous Message | Andrew Sullivan | 2007-05-25 17:18:52 | Re: why postgresql over other RDBMS |