Received: from mozart.si.ualg.pt (mozart.si.ualg.pt [193.136.224.2]) by postgresql.org (8.11.3/8.11.1) with ESMTP id f5PF8pa70524 for ; Mon, 25 Jun 2001 11:08:52 -0400 (EDT) (envelope-from llsousa@ualg.pt) Received: from ualg.pt (llsousa@corisco.uceh.ualg.pt [10.10.20.126]) by mozart.si.ualg.pt (8.9.1/8.9.1) with ESMTP id QAA358471 for ; Mon, 25 Jun 2001 16:08:44 +0100 (WEST) Message-ID: <3B3753FB.2E1BA9B0@ualg.pt> Date: Mon, 25 Jun 2001 16:08:44 +0100 From: Luis Sousa Organization: Universidade do Algarve X-Mailer: Mozilla 4.76 [en] (X11; U; Linux 2.2.17-compact i686) X-Accept-Language: en, pt MIME-Version: 1.0 To: pgsql sql Mailing List Subject: Problems using a rule with the WHERE clause Content-Type: multipart/alternative; boundary="------------E369099EBFCBD69606916C98" X-Archive-Number: 200106/401 X-Sequence-Number: 3698 --------------E369099EBFCBD69606916C98 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Hello I'm using a rule without a WHERE clause that's working fine. Now a have to put a where clause because I only want the rule be get executed only in some occasions, but I'm having some problems with that. This rule is over a view called docentesturno. The code that I was using in the rule when I didn't had the WHERE clause was: CREATE RULE "updateturnodocente" AS ON UPDATE TO "docentesturno" DO INSTEAD ( UPDATE "pessoalEvento" SET "idPessoal" = NEW."idpessoal", ponderacao = NEW.ponderacao, envolvimento = NEW.envolvimento WHERE id_pe = OLD.id_pe; ); Now the code for the rule with WHERE: CREATE RULE "updateturnodocente" AS ON UPDATE TO "docentesturno" WHERE OLD.idpessoal != 0 DO INSTEAD ( UPDATE "pessoalEvento" SET "idPessoal" = NEW."idpessoal", ponderacao = NEW.ponderacao, envolvimento = NEW.envolvimento WHERE id_pe = OLD.id_pe; ); When I execute the INSERT into de view docentesturno I got the message: ERROR: Cannot update a view without an appropriate rule Do someone knows what can be the problem in this rule? Apparently I'm doing in the same way of the manual, chapter 13.7.2 !!!!!!! Best regards Luis Sousa --------------E369099EBFCBD69606916C98 Content-Type: text/html; charset=us-ascii Content-Transfer-Encoding: 7bit Hello

I'm using a rule without a WHERE clause that's working fine. Now a have to put a where clause because I only want the rule be get executed only in some occasions, but I'm having some problems with that.

This rule is over a view called docentesturno.

The code that I was using in the rule when I didn't had the WHERE clause was:

CREATE RULE "updateturnodocente" AS ON UPDATE TO "docentesturno"
 DO INSTEAD (
 UPDATE "pessoalEvento"
  SET "idPessoal" = NEW."idpessoal",
   ponderacao = NEW.ponderacao,
   envolvimento = NEW.envolvimento
  WHERE id_pe = OLD.id_pe;
 );
 

Now the code for the rule with WHERE:

CREATE RULE "updateturnodocente" AS ON UPDATE TO "docentesturno"
 WHERE OLD.idpessoal != 0
 DO INSTEAD (
 UPDATE "pessoalEvento"
  SET "idPessoal" = NEW."idpessoal",
   ponderacao = NEW.ponderacao,
   envolvimento = NEW.envolvimento
  WHERE id_pe = OLD.id_pe;
 );

When I execute the INSERT into de view docentesturno I got the message:
            ERROR:  Cannot update a view without an appropriate rule
 

Do someone knows what can be the problem in this rule?
Apparently I'm doing in the same way of the manual, chapter 13.7.2 !!!!!!!
 
 

Best regards

Luis Sousa --------------E369099EBFCBD69606916C98--