Re: Referencing any field in a trigger

Поиск
Список
Период
Сортировка
От Robert Fitzpatrick
Тема Re: Referencing any field in a trigger
Дата
Msg-id 1180114300.15450.54.camel@columbus.webtent.org
обсуждение исходный текст
Ответ на Re: Referencing any field in a trigger  (Alvaro Herrera <alvherre@commandprompt.com>)
Ответы Re: Referencing any field in a trigger  (Alvaro Herrera <alvherre@commandprompt.com>)
Список 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 по дате отправления:

Предыдущее
От: Andrew Sullivan
Дата:
Сообщение: Re: why postgresql over other RDBMS
Следующее
От: Alvaro Herrera
Дата:
Сообщение: Re: Referencing any field in a trigger