create rule and last record

Поиск
Список
Период
Сортировка
От Ernest Chiarello
Тема create rule and last record
Дата
Msg-id 3ABF5FD7.40D45FEF@dr7.cnrs.fr
обсуждение исходный текст
Список pgsql-novice
i use a "create rule on insert" in order to obtain the
sum on the column montant in the column cumul.
but the last record of the table is never updated. why ?
 

DROP
CREATE
DROP
CREATE
CREATE 9606604 1
INSERT 9606605 1
     id     | montant | cumul
-----+------+-------
 toto       |      10  |
(1 row)

INSERT 9606606 1
     id     | montant | cumul
-----+------+-------
 toto       |      10  |    10
 toto       |      20  |
(2 rows)
 

here are the queries :

drop table test3;

create table test3 (id char(10), montant float8, cumul float8);

drop function somme(bpchar);

create function somme(bpchar) returns float8 as
'select sum(montant) from test3 where
id = \$1' language 'sql';

create rule example_rule as
on insert to test3
do
update test3 set cumul = somme(new.id);

insert into test3 (id,montant) values ('toto','10');

select * from test3;

insert into test3 (id,montant) values ('toto','20');

select * from test3;
 
 

-- 
Ernest CHIARELLO, chiarello@dr7.cnrs.fr, Tel:04-72-44-56-77, Fax:04-72-44-56-73
CNRS - Delegation Vallee du Rhone
2 avenue Albert Einstein 69609 VILLEURBANNE CEDEX - FRANCE
 

В списке pgsql-novice по дате отправления:

Предыдущее
От: Mo Holkar
Дата:
Сообщение: Re: Error creating user
Следующее
От: Colby Meyer
Дата:
Сообщение: Problems accessing TCL functions