Hi, In the last SELECT I exepcted j = 0, rather than j = 1 since I use DO INSTEAD in the rule and the default value for j is 0. Am I missing something?
DROP TABLE t1 CASCADE; DROP TABLE CREATE TABLE t1 ( i INTEGER, j INTEGER DEFAULT 0 ); CREATE TABLE CREATE rule t1_ins AS ON INSERT TO t1 WHERE (EXISTS (SELECT 1 FROM t1 WHERE i = new.i)) DO INSTEAD UPDATE t1 SET j = j + 1 WHERE i = new.i; CREATE RULE INSERT INTO t1 VALUES (1); INSERT 1690668 1 SELECT * FROM t1; i | j ---+--- 1 | 1 (1 row) -- Tatsuo Ishii ---------------------------(end of broadcast)--------------------------- TIP 7: don't forget to increase your free space map settings