Coming from Oracle - trigger question

Поиск
Список
Период
Сортировка
От Graeme Merrall
Тема Coming from Oracle - trigger question
Дата
Msg-id NNEKJJAGMOPDHMDJNLBJCELKCBAA.GBMerrall@aol.com
обсуждение исходный текст
Ответы Re: Coming from Oracle - trigger question  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-general
I'm mucking about playing with triggers and functions and in Oracle it's
possible to check that a trigger isn't actually acting on a field you want
to update.
The function below will update the 'dirty' column as long as you're not
performing an operation on the 'dirty' as part of your SQL statement

CREATE OR REPLACE TRIGGER before_nodes_update
before update on nodes
for each row
begin
    if not updating('DIRTY') then
       :new.dirty := 1;
       :new.modified := sysdate;
    end if;
end;

Hence, "UPDATE nodes SET text='updating' WHERE node=1" would fire the
trigger and "UPDATE nodes SET dirty=0 WHERE node=1" would not fire the
trigger since we're updating the dirty column in the query.

Now I'm after the same functionality in postgres. Is there a way around
this? I have a feeling that rules my acheive what I'm after but it seems a
bit overkill for a simple column update.

Cheers,
 Graeme


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

Предыдущее
От: Hiroshi Inoue
Дата:
Сообщение: Re: ODBC Error
Следующее
От: "Henrik Steffen"
Дата:
Сообщение: Re: Serious Crash last Friday