Search Postgresql Archives

Re: Trigger for Audit Table

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Bill Moseley <moseley@xxxxxxxx> 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


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux