Received: from smtp.ualg.pt (smtp.ualg.pt [193.136.224.8]) by postgresql.org (8.11.3/8.11.4) with ESMTP id g1IC9xE29604 for ; Mon, 18 Feb 2002 07:10:00 -0500 (EST) (envelope-from llsousa@ualg.pt) Received: from localhost (smtp.ualg.pt [127.0.0.1]) by smtp.ualg.pt (Postfix) with ESMTP id AA4544BBA8 for ; Mon, 18 Feb 2002 12:10:01 +0000 (WET) Received: from ualg.pt (corisco.uceh.ualg.pt [10.10.20.126]) by smtp.ualg.pt (Postfix) with ESMTP id E4F134BB4C for ; Mon, 18 Feb 2002 12:10:00 +0000 (WET) Message-ID: <3C70EF18.4090904@ualg.pt> Date: Mon, 18 Feb 2002 12:10:00 +0000 From: Luis Sousa User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:0.9.5) Gecko/20011023 X-Accept-Language: en MIME-Version: 1.0 To: pgsql-sql Subject: Sequence in the rules Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by AMaViS snapshot-20010714 X-Archive-Number: 200202/205 X-Sequence-Number: 6630 Hi everybody I'm running on Postgresql 7.1.3. I have four rules for update for a view, whose definition are: -- UPDATE0 CREATE RULE "infoturno_r_update0" AS ON UPDATE TO "infoturno" DO INSTEAD NOTHING; -- UPDATE1 CREATE RULE "infoturno_r_update1" AS ON UPDATE TO "infoturno" WHERE NEW.cod_disciplina != OLD.cod_disciplina OR NEW.var != OLD.var OR NEW.tipo != OLD.tipo OR NEW.turno != OLD.turno DO INSTEAD ( SELECT infoturno_f_update1(OLD.id_e,NEW.cod_disciplina,NEW.var,NEW.tipo,NEW.turno,OLD.grau,OLD.curso,OLD.ramo,OLD."anoCurricular",OLD."anoLectivo") AS ok; ); -- UPDATE2 CREATE RULE "infoturno_r_update2" AS ON UPDATE TO "infoturno" WHERE NEW.grau != OLD.grau OR NEW.curso != OLD.curso OR NEW.ramo != OLD.ramo OR NEW."anoCurricular" != OLD."anoCurricular" DO INSTEAD ( SELECT infoturno_f_update2(OLD.id_e,OLD.grau,OLD.curso,OLD.ramo,OLD."anoCurricular",NEW.grau,NEW.curso,NEW.ramo,NEW."anoCurricular",OLD."anoLectivo") AS ok; ); -- UPDATE3 CREATE RULE "infoturno_r_update3" AS ON UPDATE TO "infoturno" WHERE (NEW.cod_disciplina != OLD.cod_disciplina OR NEW.var != OLD.var OR NEW.tipo != OLD.tipo OR NEW.turno != OLD.turno) AND (NEW.grau != OLD.grau OR NEW.curso != OLD.curso OR NEW.ramo != OLD.ramo OR NEW."anoCurricular" != OLD."anoCurricular") DO INSTEAD ( SELECT test1() AS ok1; SELECT test2() AS ok2; SELECT infoturno_f_update1(OLD.id_e,NEW.cod_disciplina,NEW.var,NEW.tipo,NEW.turno,OLD.grau,OLD.curso,OLD.ramo,OLD."anoCurricular",OLD."anoLectivo") AS ok; SELECT infoturno_f_update2(OLD.id_e,OLD.grau,OLD.curso,OLD.ramo,OLD."anoCurricular",NEW.grau,NEW.curso,NEW.ramo,NEW."anoCurricular",OLD."anoLectivo") AS ok; ); The rule infoturno_r_update3 must run both functions when that condition happens, but the problem is that the first rule that is runned is infoturno_r_update1. When it passes in the rule infoturno_r_update3, the condition isn't already true, because the values were changed inside the rule that runned. How can I define that the first rule to be checked is infoturno_r_update3 and then it tries the others ? Thanks in advance. PS: I hope it's clear the definition that I use for the rules. Luis Sousa