comparing OLD and NEW in update trigger..

Поиск
Список
Период
Сортировка
От Alex Mayrhofer
Тема comparing OLD and NEW in update trigger..
Дата
Msg-id 43D882AE.5090404@nona.net
обсуждение исходный текст
Ответы Re: comparing OLD and NEW in update trigger..  (Richard Huxton <dev@archonet.com>)
Список pgsql-general
Hi there,

i'm planning to use the following trigger function to update a timestamp of
a row when it is UPDATEd:

CREATE OR REPLACE modified_trigger() RETURNS opaque AS $$
BEGIN
         NEW.modify_timestamp := now();
END;
$$ LANGUAGE SQL;

Since i like to use the same trigger procedure for various tables, i'm
planning to keep it very generic.

What i'd like to do now is to just update the modify_timestamp column if OLD
and NEW are different. I'd LOOP over the row elements, and compare each
column of OLD with NEW, and bailing out if there's a difference.

I'd appreciate your help on the following two questions:

- How can i get the column names of NEW/OLD? Is there a set returning
function for this?
- Is there a more efficient way to compare whole rows?

thanks,

Alex Mayrhofer
---
http://nona.net/features/map/


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

Предыдущее
От: Agnes Bocchino
Дата:
Сообщение: Re: Initdb panic: invalid record offset at 0/0 creating
Следующее
От: Benjamin Smith
Дата:
Сообщение: Re: Postgresql Segfault in 8.1