Skip site navigation (1) Skip section navigation (2)

Triggers and INHERITS

From: Joachim Zobel <jzobel(at)heute-morgen(dot)de>
To: pgsql-general(at)postgresql(dot)org
Subject: Triggers and INHERITS
Date: 2004-11-29 18:10:35
Message-ID: 1101713804.3630.12.camel@localhost (view raw or flat)
Thread:
Lists: pgsql-general
Hi.

I want to use a table
 
CREATE TABLE stats (
    upd TIMESTAMP, 
    crt TIMESTAMP DEFAULT NOW()
);

with inheritance

CREATE sometable (
)
INHERITS stats

to automatically maintain update dates. However the obviuos trigger 

CREATE OR REPLACE 
FUNCTION stat_upd()
RETURNS TRIGGER 
AS '
BEGIN
	new.upd	= ''now'';
	RETURN new;
END;
' LANGUAGE plpgsql;

CREATE TRIGGER stat_upd 
BEFORE UPDATE 
ON stats
FOR EACH ROW
EXECUTE PROCEDURE stat_upd();

does not work. Is there a way around this?

Doing a CREATE TRIGGER for all child tables is not a good option since I
am checking if it is possible to build a generic database (a shop with
catalog and cart) that can be customized through inheritance.

Sincerely,
Joachim

-- 
"... ein Geschlecht erfinderischer Zwerge, die fuer alles gemietet werden 
koennen."                            - Bertolt Brecht - Leben des Galilei 


pgsql-general by date

Next:From: Mark DexterDate: 2004-11-29 19:48:37
Subject: VACUUM and ANALYZE Follow-Up
Previous:From: Scott CainDate: 2004-11-29 18:01:54
Subject: Re: ERROR: could not access status of transaction 210

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group