From: Mark Gibson <gibsonm@cromwell.co.uk>
To: David B <postgresql@thegatelys.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: Elegant way to monitor for changes in a trigger and migrate
Date: Wed, 11 Feb 2004 08:39:24 +0000
Message-ID: <4029EA3C.5000509@cromwell.co.uk> (raw)
In-Reply-To: <GOEGKICPFOPNLIEIHGFJMEHHCHAA.postgresql@thegatelys.com>
References: <GOEGKICPFOPNLIEIHGFJMEHHCHAA.postgresql@thegatelys.com>
David B wrote:
>Folks,
>
>Perhaps you can help....hell I'm sure you can!
>I want to monitor for changes in a table and migrate the OLD. record to
>audit table.
>
>Is there an elegant or generic way to do this so I can use across multiple
>tables with little change.
>
>
You can use a rule to do this:
CREATE RULE cust_audit AS ON UPDATE OR DELETE TO cust DO
INSERT INTO cust_hist SELECT OLD.*;
cust_hist should be identical to cust without a primary key or any
constraints/foreign keys etc.
I'm currently working on an auditing system at present, and will be
releasing it
soon if anyone is interested. It needs some cleaning up first, when I
have time.
--
Mark Gibson <gibsonm |AT| cromwell |DOT| co |DOT| uk>
Web Developer & Database Admin
Cromwell Tools Ltd.
Leicester, England.
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: gibsonm@cromwell.co.uk, postgresql@thegatelys.com
Subject: Re: Elegant way to monitor for changes in a trigger and migrate
In-Reply-To: <4029EA3C.5000509@cromwell.co.uk>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox