Re: Calcular campo

From: Jaime Casanova <systemguards(at)gmail(dot)com>
To: José Fermín francisco ferreras <josefermin54(at)hotmail(dot)com>
Cc: pgsql-es-ayuda(at)postgresql(dot)org
Subject: Re: Calcular campo
Date: 2005-12-08 18:07:38
Message-ID: c2d9e70e0512081007q454a68a5hdda0fa74649dfded@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-es-ayuda

On 12/8/05, José Fermín francisco ferreras <josefermin54(at)hotmail(dot)com> wrote:
> costo_art lo guardo en la tabla articulo:
>

entonces lo que tu quieres hacer es algo como:

CREATE OR REPLACE FUNCTION calcularganancia() RETURNS "trigger" AS
$BODY$
DECLARE
costo_art numeric(11,2);
BEGIN
/* New function body */

SELECT INTO costo_art costo_art FROM miesquema.articulo
WHERE codigo_art = new.codigo_art;

new.porciento_pre := (new.precio_pre - costo_art) / costo_art * 100;
RETURN new;
END;
$BODY$
LANGUAGE 'plpgsql' IMMUTABLE;
ALTER FUNCTION calcularganancia() OWNER TO postgres;

--
Atentamente,
Jaime Casanova
(DBA: DataBase Aniquilator ;)

In response to

Browse pgsql-es-ayuda by date

  From Date Subject
Next Message Paul Elguera Meza 2005-12-08 18:12:56 Re: Conexion postgresql con VB
Previous Message José Fermín francisco ferreras 2005-12-08 18:01:30 Re: Calcular campo