Re: timestamp (MS SQLServer's rowversion) functionality

Поиск
Список
Период
Сортировка
От Andrew Hammond
Тема Re: timestamp (MS SQLServer's rowversion) functionality
Дата
Msg-id 1155216510.452118.282090@h48g2000cwc.googlegroups.com
обсуждение исходный текст
Ответы Re: timestamp (MS SQLServer's rowversion) functionality  ("Aaron Bono" <postgresql@aranya.com>)
Список pgsql-sql
Tomski wrote:
> Hello!
> As many of you know, SQL Server (2000) has peculiar data type "timestamp"
> which is not SQL standard timestamp. In fact it is "rowversion" type. It
> makes tha field to be updated with current timestamp when row is updated or
> inserted.
> Is there any similiar functionality in PostgreSQL? If not, how to achieve
> that?
> I need such fields in many tables. Maybe triggers could help? Do I have to
> write functions for each trigger for each table? Or can it be done by one
> function with parameters? Partial or final solutions are welcome :)

Create your table with a column of type timestamp and DEFAULT (now())
and you have the on insert functionality. You need to use triggers to
get the on update fuctionality (and also for inserts if you don't trust
the application to leave it default). I think this is actually covered
by an example in the triggers documentation for postgres. If not then
there's certainly a full code solution in the archives of this list.
Please do some research before asking questions to the list.

Drew



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

Предыдущее
От: Chad Voelker
Дата:
Сообщение: Re: Function Temp Table Woes
Следующее
От: "Jonathan Sinclair"
Дата:
Сообщение: