From: | "Mario Soto Cordones" <msotocl(at)gmail(dot)com> |
---|---|
To: | "'Fernandos Siguenza'" <fsigu(at)hotmail(dot)com>, "'Foro Postgres'" <pgsql-es-ayuda(at)postgresql(dot)org> |
Subject: | RE: Ayuda con funcion |
Date: | 2009-05-25 13:53:29 |
Message-ID: | 002201c9dd40$36f8cbd0$a4ea6370$@com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-es-ayuda |
Al parecer la definición de tu función está mal, debes indicarle que vas a
devolver :
Ej:
CREATE OR REPLACE FUNCTION my_fun (integer,INTEGER)
RETURNS SETOF "public"."ty_filial" AS
$body$
SELECT
..
from .
where
..
$body$
LANGUAGE 'sql' VOLATILE RETURNS NULL ON NULL INPUT SECURITY INVOKER;
Por otro lado creo que estas tratando de abrir un cursor cSaldos, pero no
lo tienes declarado
Personalmente no te recomiendo utilizar cursores
Espero te sirva
atentamente,
Mario Soto Cordones
medio ambiente Porfavor antes de Imprimir éste correo, piense en los
árboles de nuestro planeta.
De: pgsql-es-ayuda-owner(at)postgresql(dot)org
[mailto:pgsql-es-ayuda-owner(at)postgresql(dot)org] En nombre de Fernandos Siguenza
Enviado el: lunes, 25 de mayo de 2009 9:41
Para: Foro Postgres
Asunto: [pgsql-es-ayuda] Ayuda con funcion
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. Sign up today.
<http://windowslive.com/Explore/Hotmail?ocid=TXT_TAGLM_WL_hotmail_acq_faster
_112008>
__________ Information from ESET Smart Security, version of virus signature
database 4101 (20090525) __________
The message was checked by ESET Smart Security.
From | Date | Subject | |
---|---|---|---|
Next Message | Conxita Marín | 2009-05-25 16:00:54 | Problema con client_encoding='WIN1251' y base de datos UTF8 |
Previous Message | Gabriel Ferro | 2009-05-25 13:49:13 | Mejorar update |