Ver Mensaje Individual
  #5 (permalink)  
Antiguo 15/07/2009, 11:15
edwinsp
 
Fecha de Ingreso: septiembre-2008
Mensajes: 75
Antigüedad: 15 años, 8 meses
Puntos: 1
Respuesta: Problema con datos reales

Vamos desde el principio he tenido errores al explicar

--Tabla
create table detalle(
codcab character(2) not null,
codigo character(2) not null,
importe1 real not null,
importe2 real not null
);

--Funcion
CREATE OR REPLACE FUNCTION pa_grabardetalle(_codcab character,_codigo character[], _aimporte real[])
RETURNS integer AS
$BODY$
BEGIN
FOR i IN array_lower(_aimporte,1) .. array_upper(_aimporte,1) LOOP
nitem:=nitem+1;
insert into detalle(codcab,codigo,importe1,importe2)
VALUES(_codcab,_codigo[i],_aimporte[i][1],_aimporte[i][2]);
END LOOP;
if (select sum(importe1)-sum(importe2) from detalle Where codcab=_codcab)<>0 then
RAISE EXCEPTION 'las sumas no coinciden..!';
RETURN 0;
end if;
RETURN 1;
END;

--Ejecucion que no corre
Select "pa_grabardetalle"('10',ARRAY['10','20','30','40'],ARRAY[[13930.00,0.0],[2646.7,0.0],[165.77,0.0],[0.0,16742.47]]) as resultado;

----Ejecucion que corre
Select "pa_grabardetalle"('20',ARRAY['10','20','40'],ARRAY[[100.00,0.0],[19,0.0],[0.0,119]]) as resultado;

Espero ser ahora preciso disculpa por los errores anteriores