Re: Referencing any field in a trigger

Поиск
Список
Период
Сортировка
От Robert Fitzpatrick
Тема Re: Referencing any field in a trigger
Дата
Msg-id 1180124114.15450.67.camel@columbus.webtent.org
обсуждение исходный текст
Ответ на Re: Referencing any field in a trigger  (Alvaro Herrera <alvherre@commandprompt.com>)
Список pgsql-general
On Fri, 2007-05-25 at 13:45 -0400, Alvaro Herrera wrote:
> Robert Fitzpatrick wrote:
>
> > 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 '%%%'.
>
> Well, do a foreach ($_TD->{new}) or foreach (keys $_TD->{new}) (not sure
> of the exact syntax but if you're used to Perl you can figure it out).
>

You gotta love pgsql, took a bit, but done...

foreach $i (keys %{$_TD->{new}}) {
    if (${$_TD->{new}}{$i} eq '*') {
        ${$_TD->{new}}{$i} = '%%%';
    } else {
        ${$_TD->{new}}{$i} =~ s/\*/\%/g;
    }
}
return  "MODIFY";

--
Robert


В списке pgsql-general по дате отправления:

Предыдущее
От: Andrew Sullivan
Дата:
Сообщение: Re: why postgresql over other RDBMS
Следующее
От: Erik Jones
Дата:
Сообщение: Re: why postgresql over other RDBMS