Re: problemas con trigger

From: Raul Andres Gutierrez Alejo <raulandrez(at)gmail(dot)com>
To: pgsql-es-ayuda(at)postgresql(dot)org
Subject: Re: problemas con trigger
Date: 2012-11-07 21:22:16
Message-ID: 509AD108.7050900@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-es-ayuda

NEW es valido en INSERT Y UPDATE
OLD es valido en UPDATE Y DELETE
con esta función puede probar los valores para cualquier tabla.
CREATE OR REPLACE FUNCTION tr_datos_d()
RETURNS trigger AS
$BODY$
DECLARE
BEGIN
IF TG_OP = 'INSERT' THEN
RAISE NOTICE 'INSERT NEW %',NEW;
RETURN NEW;
END IF;
IF TG_OP = 'UPDATE' THEN
RAISE NOTICE 'UPDATE NEW %',NEW;
RAISE NOTICE 'UPDATE OLD %',OLD;
RETURN NEW;
END IF;
IF TG_OP = 'DELETE' THEN
RAISE NOTICE 'DELETE OLD %',OLD;
RETURN OLD;
END IF;
END;$BODY$
LANGUAGE plpgsql VOLATILE
COST 100;

El 07/11/2012 04:14 p.m., Jaime Casanova escribió:
> 2012/11/7 Juan <smalltalker(dot)marcelo(at)gmail(dot)com>:
>> Jaime
>>
>> Lo extraño es que para hacer el test yo use update
>> por lo que entiendo update manda inicializado el New.
>> lo raro es que ambos new y old estan en null.
>> cualquier idea sera agradecida
> y como determinas que NEW y OLD vienen en null?
> te da algun error?
>
> --
> Jaime Casanova www.2ndQuadrant.com
> Professional PostgreSQL: Soporte 24x7 y capacitación
> Phone: +593 4 5107566 Cell: +593 987171157
>
> -
> Enviado a la lista de correo pgsql-es-ayuda (pgsql-es-ayuda(at)postgresql(dot)org)
> Para cambiar tu suscripción:
> http://www.postgresql.org/mailpref/pgsql-es-ayuda

In response to

Responses

Browse pgsql-es-ayuda by date

  From Date Subject
Next Message Juan 2012-11-08 00:27:25 Re: problemas con trigger
Previous Message Jaime Casanova 2012-11-07 21:14:20 Re: problemas con trigger