From: Tatsuo Ishii <t-ishii@sra.co.jp>
To: pgsql-sql@postgresql.org
Subject: DO INSTEAD in rule
Date: Sun, 04 Jan 2004 22:51:15 +0900 (JST)
Message-ID: <20040104.225115.71101762.t-ishii@sra.co.jp> (raw)
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: t-ishii@sra.co.jp
Subject: Re: DO INSTEAD in rule
In-Reply-To: <20040104.225115.71101762.t-ishii@sra.co.jp>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox