Skip site navigation (1) Skip section navigation (2)

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 12:29:25
Message-ID: 00ac01c4a61f$f7f5e1e0$f664a8c0@najib (view raw or flat)
Thread:
Lists: pgsql-general

> 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 one just compares "id", which is presumably the primary key and
> unique.
Right "id" is the primary key


> > 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
>
> 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,
> traiter, code_type_academic) - itself and one other.

Sorry, I didn't understand the manuel test procedure

What is happening here? I am doing an update and the condition is on the ID
and it is corresponding to the last Rule so why should the other rules
interfer.

Thanx for your help
Najib.





In response to

Responses

pgsql-general by date

Next:From: Thomas F.O'ConnellDate: 2004-09-29 12:35:32
Subject: EXTRACT Clarification
Previous:From: Richard HuxtonDate: 2004-09-29 12:20:02
Subject: Re: Multiple Rules :: Postgres Is confused !!

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group