Re: Multiple Rules :: Postgres Is confused !!

From: "Najib Abi Fadel" <nabifadel(at)usj(dot)edu(dot)lb>
To: "Richard Huxton" <dev(at)archonet(dot)com>
Cc: "generalpost" <pgsql-general(at)postgresql(dot)org>
Subject: Re: Multiple Rules :: Postgres Is confused !!
Date: 2004-09-29 11:40:19
Message-ID: 008e01c4a619$1ba296d0$f664a8c0@najib
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


Details:

I have a table "transactions_sco" and a view "transactions_sco_v" defined as
:
create view transactions_sco_v as select * from transactions_sco;

I have the following Rules:

CREATE RULE transactions_sco_up1 AS ON
UPDATE TO transactions_sco_v DO INSTEAD UPDATE transactions_sco SET traiter
= new.traiter WHERE
(((((transactions_sco.cursus_id = old.cursus_id) AND
(transactions_sco.vers_id = old.vers_id))
AND (transactions_sco.traiter = old.traiter)) AND
(transactions_sco.code_type_academic = old.cod
e_type_academic)) AND (transactions_sco.cod_etu = old.cod_etu));

CREATE RULE transactions_sco_up2 AS ON
UPDATE TO transactions_sco_v DO INSTEAD UPDATE transactions_sco SET traiter
= new.traiter WHERE
((((transactions_sco.cursus_id = old.cursus_id) AND
(transactions_sco.vers_id = old.vers_id)) A
ND (transactions_sco.traiter = old.traiter)) AND
(transactions_sco.code_type_academic = old.code
_type_academic));

CREATE RULE transactions_sco_up8 AS ON
UPDATE TO transactions_sco_v DO INSTEAD UPDATE transactions_sco SET traiter
= new.traiter WHERE
(transactions_sco.id = old.id);

Now look what is happening:

SELECT count(1) from transactions_sco where traiter='f';
count
-------
17591

update transactions_sco_v set traiter='t' where id = 53597;
UPDATE 1

SELECT count(1) from transactions_sco where traiter='f';
count
-------
17589

AS YOU CAN SEE TWO ROWS WHERE UPDATED INSTEAD OF ONE !!
THE COMMON THINGS BETWEEN THE TWO ROWS IS THAT THE FIELDS: cod_etu,
cursus_id,vers_id,code_type_academic are the same

IF I REMOVE the rules transactions_sco_up1 and transactions_sco_up2 the
update works fine ...

Thx for any help.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Martijn van Oosterhout 2004-09-29 11:43:11 Re: About PostgreSQL's limit on arithmetic operations
Previous Message Shridhar Daithankar 2004-09-29 11:21:30 Re: About PostgreSQL's limit on arithmetic operations