Re: [GENERAL] Multiple Rules :: Postgres Is confused !!

2004-09-30 Thread Richard Huxton
Najib Abi Fadel wrote: ALL rules get executed. Conditions get combined (actually, parse trees get merged). If i am getting this right the update command: "UPDATE foo_v SET b='xxx';" will first get the "a" values (2 and 5) from the view and then execute the update on this rows. ? So im my case, wh

Re: [GENERAL] Multiple Rules :: Postgres Is confused !!

2004-09-29 Thread Najib Abi Fadel
> ALL rules get executed. Conditions get combined (actually, parse trees > get merged). > > === BEGIN rule_test.sql === > CREATE TABLE foo (a int4 PRIMARY KEY, b text); > > COPY foo FROM stdin; > 1 aaa > 2 bbb > 3 ccc > 4 aaa > 5 bbb > 6 ccc > \. > > CREATE VIEW foo_v AS SELECT * FROM foo WHERE b=

Re: [GENERAL] Multiple Rules :: Postgres Is confused !!

2004-09-29 Thread Richard Huxton
Najib Abi Fadel wrote: 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 Because that's what you asked upd1/2 to do for you. To see what is happening, try selecting row id=5

Re: [GENERAL] Multiple Rules :: Postgres Is confused !!

2004-09-29 Thread Martijn van Oosterhout
> > Because that's what you asked upd1/2 to do for you. To see what is > > happening, try selecting row id=53597 then manually running each rule > > yourself, substituting in the OLD.foo from your selected row. You should > > find that there are two rows that match 53597 on (cursus_id, vers_id, > >

Re: [GENERAL] Multiple Rules :: Postgres Is confused !!

2004-09-29 Thread Najib Abi Fadel
> This means upd1 is redundant since any rows affected by upd1 *must* be > affected by upd2. OK > > 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); > > OK, this on

Re: [GENERAL] Multiple Rules :: Postgres Is confused !!

2004-09-29 Thread Richard Huxton
Najib Abi Fadel wrote: 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 transac

Re: [GENERAL] Multiple Rules :: Postgres Is confused !!

2004-09-29 Thread Najib Abi Fadel
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 trait

Re: [GENERAL] Multiple Rules :: Postgres Is confused !!

2004-09-29 Thread Richard Huxton
Najib Abi Fadel wrote: WHY IS THAT HAPPENNING ?? I can provide more details if anyone is ready to help ... You will need to provide if anyone is to help. One thing you need to consider is that rules are basically like macros, with all the issues that can have. -- Richard Huxton Archonet Ltd -

[GENERAL] Multiple Rules :: Postgres Is confused !!

2004-09-29 Thread Najib Abi Fadel
Hi all i am running PostgreSQL 7.3.2,   i have a VIEW for which i implemented multiple RULES on UPDATE.   The weird think is that the Update Query corresponding to one of the rules is updating MULTIPLE ROWS  even though it should only update one ROW !!   THE WEIRDEST is that when i remove 2