On Fri, Mar 09, 2007 at 01:27:51PM -0800, [EMAIL PROTECTED] wrote:
> You can/should create it as an AFTER UPDATE trigger. The OLD row will
> contain the previous values.
Curiously, also works with a BEFORE UPDATE.
Off to review the docs
--
Bill Moseley
[EMAIL PROTECTED]
-
You can/should create it as an AFTER UPDATE trigger. The OLD row will
contain the previous values.
eg:
INSERT INTO template_history
( template_id, path, content, last_updated_time, person )
values
(OLD.id, OLD.path, OLD.content, OLD.last_updated_time, OLD.person);
On Mar 9, 2:45 pm, [EMA
Bill Moseley <[EMAIL PROTECTED]> 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 ch
On Fri, Mar 09, 2007 at 06:50:39PM -0500, Tom Lane wrote:
> Bill Moseley <[EMAIL PROTECTED]> writes:
> > I'm asking for a sanity check:
>
> > And then an audit table:
>
> > create table template_history (
> > id SERIAL PRIMARY KEY,
> > template_id inte
Bill Moseley <[EMAIL PROTECTED]> writes:
> I'm asking for a sanity check:
> And then an audit table:
> create table template_history (
> id SERIAL PRIMARY KEY,
> template_id integer NOT NULL REFERENCES template ON DELETE
> CASCADE,
> path
I'm asking for a sanity check:
This is a very simple audit table setup where I use a BEFORE UPDATE
trigger to save an existing record.
The table stores templates (for a CMS) and looks something like this:
create table template (
id SERIAL PRIMARY KEY,
path