Received: from txino.mikasa.eh (122-ZARA-X22.libre.retevision.es [62.82.245.122]) by postgresql.org (8.11.3/8.11.1) with ESMTP id f4M3ixA87460 for ; Mon, 21 May 2001 23:45:00 -0400 (EDT) (envelope-from txinete@wanadoo.es) Received: from txino.mikasa.eh (localhost.localdomain [127.0.0.1]) by txino.mikasa.eh (Postfix) with SMTP id 9370265539 for ; Tue, 22 May 2001 05:56:38 -0400 (EDT) Content-Type: text/plain; charset="iso-8859-1" From: "J.Fernando Moyano" Organization: SymeX To: pgsql-sql@postgresql.org Subject: RULES Date: Tue, 22 May 2001 05:56:38 -0400 X-Mailer: KMail [version 1.2] MIME-Version: 1.0 Message-Id: <01052205563802.07510@txino.mikasa.eh> Content-Transfer-Encoding: 8bit X-Archive-Number: 200105/233 X-Sequence-Number: 3050 -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 I need something like this ..... CREATE RULE piezas_add AS ON insert TO piezas DO update materia_prima set usadas=(usadas+1) where n_material=new.n_material; CREATE RULE piezas_delete AS ON delete TO piezas DO update materia_prima set usadas=(usadas-1) where n_material=old.n_material; Inserting all is OK. ... but in deleting operations nothing changes. Can someone help me ?? And .... i would like to do the same when updating .... Can i do something like this ?? What is the rigth syntax ?? Must i create 2 rules to perform the action ??? CREATE RULE piezas_update AS ON update TO piezas.n_material DO update materia_prima set usadas=(usadas-1) where n_material=old.n_material ???WHAAAT??? update materia_prima set usadas=(usadas+1) where n_material=new.n_material thanks !!! fer - -- Fernando Moyano Frase del día: - -------------- El que retiene algo que no necesita es igual a un ladrón. (M Gandhi) (*) SymeX ==> http://symex.lantik.com (*) WDBIL ==> http://wdbil.sourceforge.net (*) Informate sobre LINUX en http://www.linux.org -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.4 (GNU/Linux) Comment: For info see http://www.gnupg.org iD8DBQE7CjfWoZaf9MvtDvcRAkYbAJ9VfQGtF4NCQ8nOKegtLPKn0NwX5ACeLA7O wyQnOfKGH1xRYnYBtB6jvW8= =OB6B -----END PGP SIGNATURE-----