From: | Roberto Rodríguez Pino <rodpin(at)gmail(dot)com> |
---|---|
To: | "Edwin Quijada" <listas_quijada(at)hotmail(dot)com> |
Cc: | pgsql-es-ayuda(at)postgresql(dot)org |
Subject: | Re: declarando una variable en funcion |
Date: | 2008-06-18 17:09:47 |
Message-ID: | d865cadf0806181009y16c67fd3p3009016e6dcb0304@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-es-ayuda |
Ahi funciono de pelos. Aca esta la funcion que queria hacer.
CREATE OR REPLACE FUNCTION ingresarcosto(_idproveedor integer,
_idarticulo character varying, _costoultimo double precision, _fecha
date, _cantidad integer)
RETURNS integer AS
$BODY$
DECLARE
costoTemp "float8"; --uN COSTO ENTERO??
costo_Inventario "float8";
CUR integer;
BEGIN
select INTO costoTemp costoultimo from costo where idarticulo=$2 and
flag=true;
costo_Inventario := ((costoTemp+_costoultimo)/2);
insert into costo (idproveedor, idarticulo, costoultimo, fecha,
cantidad,costoinventario)
values ($1, $2, $3, $4, $5,costo_Inventario);
update costo set flag=false where idarticulo=$2;
update costo set flag=true where idcosto=(select
currval('costo_idcosto_seq')::int);
select INTO CUR currval('costo_idcosto_seq')::int;
RETURN(CUR);
END
$BODY$
LANGUAGE 'PLPGsql' VOLATILE;
Gracias a todos!
Roberto
--
visita mi weblog!
http://trasto.hopto.org
Softwarelibre(at)diinf
http://softwarelibre.diinf.usach.cl
From | Date | Subject | |
---|---|---|---|
Next Message | Roberto Rodríguez Pino | 2008-06-18 17:14:01 | ¿Existe alguna IDE para postgres? |
Previous Message | Roberto Rodríguez Pino | 2008-06-18 16:50:34 | Re: declarando una variable en funcion |