Re: Disabling triggers in a transaction

Поиск
Список
Период
Сортировка
От Net Virtual Mailing Lists
Тема Re: Disabling triggers in a transaction
Дата
Msg-id 20050309060841.19330@mail.net-virtual.com
обсуждение исходный текст
Ответ на Disabling triggers in a transaction  (Jay Guerette <jayguerette@gmail.com>)
Ответы Re: Disabling triggers in a transaction  (Alban Hertroys <alban@magproductions.nl>)
Список pgsql-general
>It is the only known way to control triggers though it isn't regularly
>tested by the developers.


I think I've come up with another way.. I posted this recently, but did
not get any feedback on it so I'm not sure how dumb it is...  It is
working really great for me though....


All I did was added an extra column to my table (I called it
"batch_process").  Then in
the trigger do something like (in whichever function you are calling):

IF NEW.batch_update IS NOT NULL AND NEW.batch_update = ''t'' THEN
  NEW.batch_process := NULL;
  RETURN NULL;
END IF;
.. whatever the rest of transaction is


Then when doing an insert, just:

INSERT INTO table (..., batch_process) VALUES (..., 't') when you want the
trigger not to fire...

Or an update:

UPDATE TABLE table SET ...., batch_process = 't' ....


I'm not sure sure how to make it work on a function called from a delete
trigger though.. ;-(

- Greg


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

Предыдущее
От: "Uwe C. Schroeder"
Дата:
Сообщение: Re: PostgreSQL still for Linux only?
Следующее
От: Tom Lane
Дата:
Сообщение: Re: PostgreSQL still for Linux only?