rules or trigers?

From: Marcin Mazurek <M(dot)Mazurek(at)poznan(dot)multinet(dot)pl>
To: pgsql-general(at)postgresql(dot)org
Subject: rules or trigers?
Date: 2000-08-30 20:32:17
Message-ID: 20000830223217.A26598@poznan.mtl.pl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Simple example to make things clearer.
CREATE TABLE tab (id INT SERIAL PRIMARY KEY, sth TEXT); --main table
CREATE TABLE log_tab(id INT, sth TEXT); --table to maintain logs in it

CREATE RULE tab_log_ins AS ON INSERT TO tab DO
INSERT INTO log_tab VALUES (new.id, new.sth);

INSERT INTO tab (sth) VALUES ('something');
when I insert new raw in tab, id field differs (rises by one) from id in
log_tab, how can i avoid it?

CREATE RULE tab_log_upd AS ON UPDATE TO tab DO
INSERT INTO log_tab VALUES (new.id, new.sth);

it happens nothing when I update one of field in tab. The same happens
with ON DELETE RULE.
Am I missing something or it's not yet implemented?

Do You think I should use triggers to log information about changing data?

btw. Did You know there will be conference about postgresql in Poland?
Anyone going to be there?:)

Marcin Mazurek

--
Kierownik Działu Systemowego
MULTINET SA o/Poznan
http://www.multinet.pl/

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Adam Lang 2000-08-30 20:35:43 Post install - error
Previous Message Tom Lane 2000-08-30 19:53:33 Re: vacuumdb failed