How to find out that a record has been updated

Поиск
Список
Период
Сортировка
Искать

How to find out that a record has been updated

От:
"P.V. Subramanian" <pvsmian@hotmail.com>
Дата:
Hi all

I have an application that reads the contents of a few tables every 2 hours.

If no new records have been added, and if no updates to existing records 
have been made in the last 2 hours, the app does nothing.

If some records have been updated or added, the app does some work, and 
marks the record as processed.

Currently anyone updating a record is expected to mark it manually as 
needing processing. Otherwise the application doesn't know.

Is there a better, more user friendly way, for the app to automatically find 
out which records have been updated. Maybe a column that has a time field 
that Postgres can update to "now" each time an update is made?

Thanks

PVS


_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp

Re: How to find out that a record has been updated

От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
"P.V. Subramanian"  writes:
> If some records have been updated or added, the app does some work, and 
> marks the record as processed.

> Currently anyone updating a record is expected to mark it manually as 
> needing processing. Otherwise the application doesn't know.

> Is there a better, more user friendly way, for the app to automatically find 
> out which records have been updated.

You don't need to change the table definition; just add an ON UPDATE
trigger that forces the marking column to be updated.

			regards, tom lane
FAQ