From: Michael Monnerie <michael.monnerie@is.it-management.at>
To: pgsql-admin@postgresql.org
Subject: fail-safe sql update triggers
Date: Fri, 3 Sep 2010 15:03:19 +0200
Message-ID: <vmime.4c80f217.42d2.c43fd4a13aa09607@zarafa14.zmi.at> (raw)
I want to log all activity from a table to a old_table. Creating an ON INSERT trigger is simple, it just needs to
INSERT INTO old_filter SELECT NEW.*;
in a procedure that is called via the trigger. But what about updates? There is no simple
UPDATE old_filter SET NEW.* WHERE id=NEW.id;
so I would need to declare each column like
UPDATE old_filter SET field1=NEW.field1,f2=NEW.f2,.... where id=NEW.id;
But that is error prone, because when the "filter" table is changed to have a new column, the UPDATE statement would not contain it. Is there a fail-proof shortcut?
mit freundlichen Grüßen
Michael Monnerie, Ing. BSc
it-management Internet Services
http://proteger.at [gesprochen: Prot-e-schee]
Tel: 0660 / 415 65 31
// Wir haben im Moment zwei Häuser zu verkaufen:
// http://zmi.at/langegg/
// http://zmi.at/haus2009/
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-admin@postgresql.org
Cc: michael.monnerie@is.it-management.at
Subject: Re: fail-safe sql update triggers
In-Reply-To: <vmime.4c80f217.42d2.c43fd4a13aa09607@zarafa14.zmi.at>
* 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