Re: Trigger question

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Trigger question
Дата
Msg-id 11871.1008891107@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Trigger question  (Pat Marchant <patmarchant@lvcablemodem.com>)
Ответы Re: Trigger question  (Pat Marchant <patmarchant@lvcablemodem.com>)
Список pgsql-novice
Pat Marchant <patmarchant@lvcablemodem.com> writes:
> if (AttributeExists(new.updated))
>    { new.updated = 'now'::datetime;}

I don't know any good way to do this in plpgsql.  It'd be moderately
straightforward in C, however, since you could look at the tuple
descriptor for the relation to see if there is a field named updated.

Dunno if you want to get involved with writing your triggers in C,
but if you want to try see
http://developer.postgresql.org/docs/postgres/trigger-manager.html

Also, there's an example that's pretty darn close to what you want to do
in contrib/spi/moddatetime.c.

            regards, tom lane

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

Предыдущее
От: Philip Hallstrom
Дата:
Сообщение: Re: FW: Random Selection from TABLE
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Using a tablename as a parameter to a function.