Re: Trigger question

Поиск
Список
Период
Сортировка
От Nelio Alves Pereira Filho
Тема Re: Trigger question
Дата
Msg-id 3A229514.2241079A@ifx.com.br
обсуждение исходный текст
Ответ на Trigger question  (Nelio Alves Pereira Filho <nelio@ifx.com.br>)
Ответы Re: Trigger question
Список pgsql-general
I got it.
But here's what I need to do: after any modification on the table, I
must run a procedure that will do some calculation, and then set these
values for each row. This calculation establishes relationships between
rows, and builds logically a tree. To accomplish all that, first I need
to unset some values, so I decided to use the BEFORE trigger to unset
these values, and the AFTER trigger to do this calculation.

Will I have to use explicit queries? And what's the real purpose of the
AFTER trigger?

Thanks


Tom Lane wrote:
>
> Nelio Alves Pereira Filho <nelio@ifx.com.br> writes:
> > create trigger set_counter after insert or update on nivel
> > for each row execute procedure set_counter();
>
> > The problem is that after I insert something, count value is still -1,
> > not 0!
>
> You want a BEFORE trigger, not an AFTER trigger.  AFTER is too late
> to affect the contents of the stored row.
>
>                         regards, tom lane

--
Nelio Alves Pereira Filho
IFX Networks
Sao Paulo / Brazil

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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: Trigger question
Следующее
От: Peter Eisentraut
Дата:
Сообщение: Re: Bug? 'psql -l' in pg_ctl?