Re: [SQL] Triggers

Поиск
Список
Период
Сортировка
От Jan Wieck
Тема Re: [SQL] Triggers
Дата
Msg-id 38723F15.9EADB8A7@debis.com
обсуждение исходный текст
Ответ на Re: [SQL] NULL  (Tom Lane <tgl@sss.pgh.pa.us>)
Ответы Re: [SQL] Triggers  (Matthew Hagerty <matthew@venux.net>)
Список pgsql-sql
Mitch Vincent wrote:

> I'm using this funtion via a trigger to total up amounts in several fields
> (and adding that value into a total field)..
>
> CREATE FUNCTION invoice_total_trigger() RETURNS OPAQUE AS '
> ...
>
> That's the function, here is the trigger.
>
> CREATE TRIGGER invoice_total_trigger AFTER INSERT OR UPDATE ON invoice
> FOR EACH ROW EXECUTE PROCEDURE invoice_total_trigger();
>
> It works for updating but not when you insert a new row. Am I doing it
> wrong?
    I wonder why it works on UPDATE at all, it shouldn't. It is an    AFTER ROW trigger and thus, the changed row you
returnshould get    ignored. Use BEFORE INSERT instead.
 
    But that it works on UPDATE indicates some bug somewhere. What    release, OS, etc. are you using?

Jan

--

#======================================================================#
# It's easier to get forgiveness for being wrong than for being right. #
# Let's break this rule - forgive me.                                  #
#========================================= wieck@debis.com (Jan Wieck) #





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

Предыдущее
От: "Mitch Vincent"
Дата:
Сообщение: Re: [SQL] Triggers
Следующее
От: Matthew Hagerty
Дата:
Сообщение: Re: [SQL] Triggers