Re: defaults on updates

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: defaults on updates
Дата
Msg-id 24956.1067700289@sss.pgh.pa.us
обсуждение исходный текст
Ответ на defaults on updates  (Martin Marques <martin@bugs.unl.edu.ar>)
Список pgsql-sql
Martin Marques <martin@bugs.unl.edu.ar> writes:
> Basically, I have 5 fields, one being a PK (SERIAL), 3 with information, and 
> the last one a timestamp field that will show the last time the register was 
> modified (tmodif which has a DEFAULT CURRENT_TIMESTAMP).

> Now, eveytime someone modifys any, or all of the 3 information fields,
> I want the tmodif field of that register to be set to now().

This is trivial to do with a trigger --- you just need something like
NEW.lastmod := now();RETURN NEW;

There's a complete example at the bottom of this page:
http://developer.postgresql.org/docs/postgres/plpgsql-trigger.html
        regards, tom lane


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

Предыдущее
От: Martin Marques
Дата:
Сообщение: defaults on updates
Следующее
От: George Essig
Дата:
Сообщение: Re: connectby