[Pgsql-ayuda] actualizar saldo

Henry Orlando Interiano henry@lamundial.hn
Tue, 15 Jul 2003 15:41:11 -0600


This is a multi-part message in MIME format.

------=_NextPart_000_0050_01C34AE7.84670270
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

 Saludo lista
Quisiera saber si esta funcion se puede llevar a cabo, ya que de devulve =
un error:

ERROR:  Set-valued function called in context that cannot accept a set

CREATE or replace FUNCTION public.fixcuenta(varchar) RETURNS SETOF =
public.cxcclient AS '
DECLARE=20
    rec cxcclient%rowtype;
    lc_codigo alias for $1;
    xsaldo numeric(14,2) :=3D 0;=20
BEGIN=20
    FOR rec IN select * from cxcclient where id_cliente =3D lc_codigo =
order by doc_fecha LOOP=20
    xsaldo :=3D xsaldo + rec.valor;
    update cxcclient set saldo=3Dxsaldo where =
cxcclient.id_transac=3Drec.id_transac;=20
END LOOP;=20
RETURN;=20
END;' LANGUAGE 'plpgsql' VOLATILE;

Gracias por su atencion.

Henry O.Interiano.
San Pedro Sula, Honduras.

------=_NextPart_000_0050_01C34AE7.84670270
Content-Type: text/html;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 5.50.4134.600" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>&nbsp;Saludo lista
<DIV>Quisiera saber si esta funcion se puede llevar a cabo, ya que de =
devulve un=20
error:</DIV>
<DIV>&nbsp;</DIV>
<DIV>ERROR:&nbsp; Set-valued function called in context that cannot =
accept a=20
set</DIV>
<DIV>&nbsp;</DIV>
<DIV>CREATE<FONT size=3D2> </FONT><FONT size=3D2>or</FONT><FONT =
size=3D2> replace=20
</FONT><FONT size=3D2>FUNCTION</FONT><FONT size=3D2> =
public.fixcuenta(varchar)=20
RETURNS SETOF public.cxcclient </FONT><FONT size=3D2>AS</FONT><FONT =
size=3D2>=20
'</FONT></DIV>
<DIV><FONT size=3D2>DECLARE </FONT></DIV>
<DIV><FONT size=3D2>&nbsp;&nbsp;&nbsp; rec =
cxcclient%rowtype;</FONT></DIV>
<DIV><FONT size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;lc_codigo alias for =
$1;</FONT></DIV>
<DIV><FONT size=3D2>&nbsp;&nbsp;&nbsp; xsaldo numeric(14,2) :=3D 0; =
</FONT></DIV>
<DIV><FONT size=3D2>BEGIN </FONT></DIV>
<DIV><FONT size=3D2>&nbsp;&nbsp;&nbsp; FOR rec IN </FONT><FONT=20
size=3D2>select</FONT><FONT size=3D2> * </FONT><FONT =
size=3D2>from</FONT><FONT size=3D2>=20
cxcclient </FONT><FONT size=3D2>where</FONT><FONT size=3D2> id_cliente =
=3D lc_codigo=20
</FONT><FONT size=3D2>order</FONT><FONT size=3D2> </FONT><FONT =
size=3D2>by</FONT><FONT=20
size=3D2> doc_fecha LOOP </FONT></DIV>
<DIV><FONT size=3D2>&nbsp;&nbsp;&nbsp; xsaldo :=3D xsaldo + =
rec.valor;</FONT></DIV>
<DIV><FONT size=3D2>&nbsp;&nbsp;&nbsp; update</FONT><FONT size=3D2> =
cxcclient=20
</FONT><FONT size=3D2>set</FONT><FONT size=3D2> saldo=3Dxsaldo =
</FONT><FONT=20
size=3D2>where</FONT><FONT size=3D2> =
cxcclient.id_transac=3Drec.id_transac;=20
</FONT></DIV>
<DIV><FONT size=3D2>END LOOP; </FONT></DIV>
<DIV><FONT size=3D2>RETURN; </FONT></DIV>
<DIV><FONT size=3D2>END;' </FONT><FONT size=3D2>LANGUAGE</FONT><FONT =
size=3D2>=20
'plpgsql' VOLATILE;</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>Gracias por su atencion.</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>Henry O.Interiano.</FONT></DIV>
<DIV><FONT size=3D2>San Pedro Sula,=20
Honduras.</FONT></DIV></FONT></DIV></BODY></HTML>

------=_NextPart_000_0050_01C34AE7.84670270--