From: | Karel Zak <zakkr(at)zf(dot)jcu(dot)cz> |
---|---|
To: | pgsql-hackers <pgsql-hackers(at)postgreSQL(dot)org> |
Subject: | RULE vs. SEQUENCE |
Date: | 2000-09-04 10:09:40 |
Message-ID: | Pine.LNX.3.96.1000904115840.219D-100000@ara.zf.jcu.cz |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Hi,
I have a question... why RULE call nexval() and data in RULE statement are
differend than data in original stmt.
An example:
create sequence a;
create table aa (id int DEFAULT nextval('a'), data text);
insert into aa (data) values ('xxxx');
insert into aa (data) values ('yyyy');
select * from aa;
id|data
--+----
1|xxxx
2|yyyy
(2 rows)
... all is right.
create table log (aid int, act text);
create rule a_ins as
on insert to aa
do insert into log (aid, act) values (NEW.id, 'INSERT');
insert into aa (data) values ('zzzz');
insert into aa (data) values ('qqqq');
test=> select * from aa;
id|data
--+----
1|xxxx
2|yyyy
4|zzzz <----------
6|qqqq
(4 rows)
select * from log;
aid|act
---+------
3|INSERT <----------
5|INSERT
(2 rows)
But I expect in 'log' table as 'aid' same number as numbers for 'zzzz' and
'qqqq'...
It's interesting feature (6.5, 7.0, 7.1...). How is a possible in RULE
obtain same data as in 'aa' table for a default data from the sequence.
Karel
From | Date | Subject | |
---|---|---|---|
Next Message | Hannu Krosing | 2000-09-04 11:01:14 | Re: RULE vs. SEQUENCE |
Previous Message | Hiroshi Inoue | 2000-09-04 09:11:19 | RE: func() & select func() |