Re: Trigger for Audit Table

Поиск
Список
Период
Сортировка
Искать
От
Tom Lane
Тема
Re: Trigger for Audit Table
Дата
Msg-id
6047.1173490805@sss.pgh.pa.us
Ответ на
Список
Дерево обсуждения
Trigger for Audit Table Bill Moseley <moseley@hank.org>
Re: Trigger for Audit Table "ksherlock@gmail.com" <ksherlock@gmail.com>
Re: Trigger for Audit Table Bill Moseley <moseley@hank.org>
Re: Trigger for Audit Table Tom Lane <tgl@sss.pgh.pa.us>
Re: Trigger for Audit Table Bill Moseley <moseley@hank.org>
Re: Trigger for Audit Table Tom Lane <tgl@sss.pgh.pa.us>
Bill Moseley  writes:
> On Fri, Mar 09, 2007 at 06:50:39PM -0500, Tom Lane wrote:
>> This is not going to work because the row's not there yet.

> This is a BEFORE *UPDATE* trigger, not a BEFORE INSERT, so the row is
> there.  The audit table is written when the primary record changes
> and the old version is written to the audit table, not the new
> version.

Well, if you want to write the old data, it's still a silly way to do
it: write the OLD.* tuple instead of forcing a fresh search of the
table.

> Ok, but as the id is a sequence.  I need to test if NEW.id is set after
> the insert -- seems like not, IIRC, and  I'd need to use curval().

You're confusing rules with triggers.  In a trigger, NEW.* and OLD.*
are physical rows and you don't need to worry about multi evaluation
or anything like that.

			regards, tom lane
В списке pgsql-general по дате отправления
От: Jeff Davis
Дата:
Сообщение: Re: Statistics
От: Bruno Wolff III
Дата:
Сообщение: Re: Setting week starting day
FAQ