Re: Problema con Funcion y Trigger

From: Martín Marqués <martin(at)bugs(dot)unl(dot)edu(dot)ar>
To: Jaime Casanova <systemguards(at)gmail(dot)com>
Cc: pgsql-es-ayuda(at)postgresql(dot)org, "P(at)blo Villad(at)" <andresv50(at)hotmail(dot)com>
Subject: Re: Problema con Funcion y Trigger
Date: 2005-07-27 21:13:43
Message-ID: 200507271813.45328.martin@bugs.unl.edu.ar
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-es-ayuda

El Mié 27 Jul 2005 17:58, Jaime Casanova escribió:
> On 7/27/05, Martín Marqués <martin(at)bugs(dot)unl(dot)edu(dot)ar> wrote:
> >
> > A ver si aun tengo esto fresco. ;-)
> >
> > CREATE OR REPLACE FUNCTION descuentox RETURNS TRIGGER AS
> > $descuento_cafex1$
> >
> > BEGIN
> > IF (TG_OP = 'INSERT') THEN
> > UPDATE cafe SET descuento=descuento-1 where
> > nombre_cafe=NEW.nombre_cafe;
> > RETURN NEW;
> > END IF;
> > RETURN NULL;
> > END;
> >
>
> porque return null? no deberia ser return old?

Totalmente. Error mio por copiar el ejemplo original sin mirarlo
detenidamente.

version final:

CREATE OR REPLACE FUNCTION descuentox RETURNS TRIGGER AS
$descuento_cafex1$

BEGIN
IF (TG_OP = 'INSERT') THEN
UPDATE cafe SET descuento=descuento-1 where
nombre_cafe=NEW.nombre_cafe;
RETURN NEW;
END IF;
RETURN OLD;
END;

--
18:08:14 up 25 days, 2:53, 1 user, load average: 1.15, 1.42, 1.34
-------------------------------------------------
Lic. Martín Marqués | SELECT 'mmarques' ||
Centro de Telemática | '@' || 'unl.edu.ar';
Universidad Nacional | DBA, Programador,
del Litoral | Administrador
-------------------------------------------------

In response to

Responses

Browse pgsql-es-ayuda by date

  From Date Subject
Next Message Julio Cesar Culebro Gonzalez 2005-07-27 21:21:09 Re: Problema con Funcion y Trigger
Previous Message Jaime Casanova 2005-07-27 20:58:13 Re: Problema con Funcion y Trigger