Ayuda con funcion

From: Fernandos Siguenza <fsigu(at)hotmail(dot)com>
To: Foro Postgres <pgsql-es-ayuda(at)postgresql(dot)org>
Subject: Ayuda con funcion
Date: 2009-05-25 13:41:25
Message-ID: COL111-W70644D10F98B4DED31C71FA1550@phx.gbl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-es-ayuda


Amigos como estan, queria ver si me pueden ayudar indicandome que esta mal en esta funcion, ya que al ejecutarla desde punto net tengo el siguiente error.

ERROR: 42601: a column definition list is only allowed for functions returning \"record\""

La funcion es la siguiente

CREATE OR REPLACE FUNCTION balanceGeneralSaldoAcumulado1(vAgeCod character varying,vFecCorte date,vTodos integer,out cSaldos refcursor,out vIngresos numeric,out vEgresos numeric)
AS
$BODY$
DECLARE

BEGIN
--Seleccionamos el total de ingresos
select into vIngresos sum(salhab-saldeb)
from salcue,cuentagrupo,cuentas
where salagecod=vAgeCod
and salmes=to_char(vFecCorte,'MM')
and salano=to_char(vFecCorte,'YYYY')
and cuegrucod=substring(salcuecod,1,1)
and cuegrutip='I'
and cuentas.cuecod=salcuecod
and cuentas.cueagecod=salcue.salagecod
and length(cuecodant)=0;

--Seleccionamos el total de egresos
select into vEgresos sum(saldeb-salhab)
from salcue,cuentagrupo,cuentas
where salagecod=vAgeCod
and salmes=to_char(vFecCorte,'MM')
and salano=to_char(vFecCorte,'YYYY')
and cuegrucod=substring(salcuecod,1,1)
and cuegrutip='E'
and cuentas.cuecod=salcuecod
and cuentas.cueagecod=salcue.salagecod
and length(cuecodant)=0;

open cSaldos for select vAgeCod as agecod,salcuecod,cuecodant,cuemov,sum(saldeb) as debe,sum(salhab) as haber,sum(saldeb-salhab) as saldo,
char_length(salcuecod) as nivel,cuegrutip as grupo
from cuentas,cuentagrupo,salcue
where cuentas.cueagecod=vAgeCod
and cuentas.cueagecod=salcue.salagecod
and cuentas.cuecod=salcue.salcuecod
and salmes=to_char(vFecCorte,'MM')
and salano=to_char(vFecCorte,'YYYY')
and cuegrucod=substring(salcuecod,1,1)
and (cuegrutip='A' or cuegrutip='P' or cuegrutip='T')
group by agecod,salcuecod,cuecodant,cuemov,cuegrutip
order by salcuecod;

return;
END;
$BODY$
LANGUAGE 'plpgsql' VOLATILE

Como puedo probar esta funcion que este correcta desde plsql, intente de esta forma pero tengo error,
select * from balanceGeneralSaldoAcumulado('010'::varchar,to_date('31122008', 'DDMMYYYY')::date,0::integer,cSaldos::refcursor,vIngresos::numeric,vEgresos::numeric);

y obtengo este error.
ERROR: column "csaldos" does not exist

Los select los probe individualmente y estan correctos.
Espero que me puedan ayudar
_________________________________________________________________
Windows Live Hotmail now works up to 70% faster.
http://windowslive.com/Explore/Hotmail?ocid=TXT_TAGLM_WL_hotmail_acq_faster_112008

Responses

Browse pgsql-es-ayuda by date

  From Date Subject
Next Message Gabriel Ferro 2009-05-25 13:49:13 Mejorar update
Previous Message Gabriel Ferro 2009-05-25 13:40:39 determinar tamaño del ciclo