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 ---------------------------(end of broadcast)--------------------------- TIP 6: explain analyze is your friend