Re: PROBLEMA CON REGLA

From: "Ing(dot) Marcos Ortí­z Valmaseda" <mlortiz(at)uci(dot)cu>
To: Fabio Arias <fharias(at)gmail(dot)com>
Cc: Lista Postgres ES <pgsql-es-ayuda(at)postgresql(dot)org>
Subject: Re: PROBLEMA CON REGLA
Date: 2009-10-23 14:22:37
Message-ID: 4AE1BC2D.7050000@uci.cu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-es-ayuda

Fabio Arias escribió:
> Muy Buenos Dias, tengo un problema de urgencia, tengo unas tablas
> particionadas, pero la regla en UPDATE no me funciona no me actualiza
> la tabla, y no se que hacer.
>
> CREATE OR REPLACE RULE transaccion_octubre_update_part AS
> ON UPDATE TO "TRANSACCION"
> WHERE old."TRAN_FECHA" >= '2009-10-01'::date AND old."TRAN_FECHA"
> <= '2009-10-31'::date
> DO INSTEAD UPDATE
> "TRANSACCION_OCTUBRE" SET "TRAN_ESTADO" = new."TRAN_ESTADO",
> "TRAN_PREAPROBADA" = new."TRAN_PREAPROBADA"
> WHERE "TRAN_ID" = old."TRAN_ID";
>
>
>
> Fabio Hernando Arias Vera
> Cel. +57 320 419 2661
>
> Mike Ditka
> <http://www.brainyquote.com/quotes/authors/m/mike_ditka.html> - "If
> God had wanted man to play soccer, he wouldn't have given us arms."
¿Por qué cuando le vas a decir a qué tabla le vas a aplicar la regla
pones su nombre entre comillas?
¿No debería ser:

CREATE OR REPLACE RULE transaccion_octubre_update_part AS
ON UPDATE TO TRANSACCION
WHERE old.TRAN_FECHA >= '2009-10-01'::date AND old.TRAN_FECHA <=
'2009-10-31'::date
DO INSTEAD UPDATE
TRANSACCION_OCTUBRE SET TRAN_ESTADO = new.TRAN_ESTADO,
TRAN_PREAPROBADA = new.TRAN_PREAPROBADA
WHERE TRAN_ID = old.TRAN_ID;

Aquí te dejo un ejemplo del libro Apress.Beginning PHP and PostgreSQL 8
From Novice to Professional para la creación de una regla UPDATE:

CREATE RULE database_books_update AS ON UPDATE TO database_books WHERE
NEW.title <> OLD.title DO INSTEAD UPDATE books SET title = NEW.title;

Otra cosa, ¿Pudieras poner tu schema de tus tablas particionadas ?
Para tener una idea de qué quieres hacer.

Saludos

--
--
"For me, the purpose is, at least partly, to have joy. Programmers often
feel joy when they can concentrate on the creative side of programming,
so Ruby is designed to make programmers happy."
Yukihiro Matsumoto (Matz), Creator of the Ruby Language

Ing. Marcos Luís Ortíz Valmaseda
System DBA && Rails New User
Centro de Tecnologías de Almacenamiento y Anális de Datos (CENTALAD)
Universidad de las Ciencias Informáticas

Linux User # 418229

http://www.freebsd.org
http://www.postgresql-es.org
http://www.postgresql.org
http://www.planetpostgresql.org
http://www.rubyonrails.org
http://www.ruby-lang.org

In response to

Responses

Browse pgsql-es-ayuda by date

  From Date Subject
Next Message juan 2009-10-23 14:35:38 Re: PROBLEMA CON REGLA
Previous Message Eveling Velásquez 2009-10-23 14:19:31 Re: max-pool-conecction