Re: After Update Triggers

Поиск
Список
Период
Сортировка
От Tomas Vondra
Тема Re: After Update Triggers
Дата
Msg-id 455E4711.8050400@fuzzy.cz
обсуждение исходный текст
Ответ на After Update Triggers  (Bob Pawley <rjpawley@shaw.ca>)
Список pgsql-general
> When I trigger 'after insert' the function doesn't work because the
> ip_op_equipment condition is an update. When I manually enter directley
> into the table this trigger works fine when both the fluid and
> ip_op_equipment are entered as one entry.
>
> When I trigger 'after update' every row in the Processes table is
> inserted into the other tables depending on the conditionals. I end up
> with multiple inserts of the same information.
>
> Is it possible to create a trigger that inserts only one row for each entry?

Hello,

I've read the whole message several times and I have to admit I still
don't understand what are you trying to do or what is going wrong.

I'm not sure what do you mean by 'when I trigger after insert' - the
trigger is defined as AFTER UPDATE so naturally it does not fire in case
of an INSERT.

Anyway the point is you can define the trigger as AFTER INSERT OR UPDATE
and use TG_OP variable, or maybe define several triggers - one for the
UPDATE, one for the INSERT.

Tomas

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

Предыдущее
От: Tomas Vondra
Дата:
Сообщение: Re: SPI
Следующее
От: Reece Hart
Дата:
Сообщение: Re: Copy command to load data into a PostgreSQL DB