Re: Generic triggers ?

Поиск
Список
Период
Сортировка
От Martijn van Oosterhout
Тема Re: Generic triggers ?
Дата
Msg-id 20070424154212.GF2579@svana.org
обсуждение исходный текст
Ответ на Generic triggers ?  ("Andy Dale" <andy.dale@gmail.com>)
Список pgsql-general
On Tue, Apr 24, 2007 at 05:35:09PM +0200, Andy Dale wrote:
> Hi,
>
> I wanted to setup a simple "generic" type trigger.  What a mean by generic
> is that i don't want to hardcode the
> NEW.<column> or OLD.<column> calls, i searched for a way to loop over
> the NEW/OLD rowtypes but could not figure out how it should be done.

You're trying to do something that pl/pgsql it notoriously bad at. I
suggest you use some more dynamic language like perl/python/etc.

> The above code does nothing useful and is only to test out the concept.  The
> problem comes from NEW.colnames[i] because the NEW rowtype does not have a
> column called colnames.  Can anyone tell me how to append the value of
> colnames[i] to NEW so it would work, or is it even possible to iterate of
> the NEW/OLD rowtype without having to know the column names ?

Not in pl/pgsql (being statically typed). In some other languages you can.

Have a nice day,
--
Martijn van Oosterhout   <kleptog@svana.org>   http://svana.org/kleptog/
> From each according to his ability. To each according to his ability to litigate.

Вложения

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

Предыдущее
От: Martijn van Oosterhout
Дата:
Сообщение: Re: How does server handle clients that disconnect ungracefully?
Следующее
От: Richard Huxton
Дата:
Сообщение: Re: Generic triggers ?