CREATE TABLE foo (name TEXT,type CHAR(1),when_added TIMESTAMP DEFAULT 'now'
);
CREATE VIEW mytype AS SELECT name, when_added FROM foo WHERE type = 'M';
CREATE RULE mytype_insert ASON INSERT TO mytype DO INSTEADINSERT INTO foo (name, type) VALUES (NEW.name, 'M');
db=# insert into foo (name, type) VALUES ('n1', 'M');
INSERT 414488 1
db=# insert into mytype (name) VALUES ('n2');
INSERT 414489 1
db=# select * from foo;name | type | when_added
------+------+------------------------n1 | M | 2000-06-15 09:53:44-04n2 | M | 2000-06-15 09:52:27-04
(2 rows)
Inserting directly into foo sets when_added to the current time.
Inserting through the view sets it to what looks like the time of
view creation.
--
Mark Hollomon
mhh@nortelnetworks.com
ESN 451-9008 (302)454-9008