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|xxxx2|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|xxxx2|yyyy4|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