fail-safe sql update triggers

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

 



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/




-- 
Sent via pgsql-admin mailing list (pgsql-admin@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-admin



[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux