RE: RE: Funciòn que devuelve un refcursor

From: ALFONSO REYES <alfonsoreyescruz(at)hotmail(dot)com>
To: Alvaro herrera 2 <alvherre(at)alvh(dot)no-ip(dot)org>, Alvaro Herrera <alvherre(at)commandprompt(dot)com>
Cc: <mlortiz(at)estudiantes(dot)uci(dot)cu>, lista ayuda postgres <pgsql-es-ayuda(at)postgresql(dot)org>
Subject: RE: RE: Funciòn que devuelve un refcursor
Date: 2008-12-09 01:19:32
Message-ID: BLU148-W3567BB890D1068A2FD072DDFFA0@phx.gbl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-es-ayuda


Estimados

Aca reprtandome nuevamente con este problema haber si me ayudan nuevamente....

Como avances les comento que ya logre hacer que la función corra pero no se porque razon la varible v_rec con el campo id_persona no tiene valor a pesar que el depurador me dice que si tiene 1 regsitro

LA FUNCIÓN danmaf.per_sp_obt_persona( '1711837219', null, null, null,'v_cur_resultado'); devuelve un refcursor

A continuaciòn anexo el código de la función:

CREATE OR REPLACE FUNCTION "danmaf"."fac_obt_cab_factura" (p_identificacion integer, p_fact_fisica varchar, p_fecha date, p_primer_nombre varchar, p_apellido_paterno varchar, p_razon_social varchar) RETURNS "pg_catalog"."refcursor" AS
$body$
DECLARE
v_cur_resultado refcursor;
v_rec record;
v_mensaje varchar(10);
BEGIN

begin
open v_cur_resultado for
SELECT danmaf.per_sp_obt_persona( '1711837219', null, null, null,'v_cur_resultado');

loop
fetch v_cur_resultado into v_rec;

EXIT WHEN NOT FOUND;
if v_rec.id_persona=4 then
v_mensaje:='Ok';
end if;
end loop;

end;

END;
$body$
LANGUAGE 'plpgsql' VOLATILE CALLED ON NULL INPUT SECURITY INVOKER;

Cualquier ayuda se agradece,

> Date: Mon, 8 Dec 2008 14:22:29 -0300
> From: alvherre(at)alvh(dot)no-ip(dot)org
> To: alfonsoreyescruz(at)hotmail(dot)com
> CC: mlortiz(at)estudiantes(dot)uci(dot)cu; pgsql-es-ayuda(at)postgresql(dot)org
> Subject: Re: [pgsql-es-ayuda] RE: Funciòn que devuelve un refcursor
>
> ALFONSO REYES escribió:
> >
> >
> > Marcos, muchas gracias por tú ayuda, pero a lo que me refiero es como debería jecutarla desde el query builder, por ejemplo a las
> > funciones que retirnan un refcursor se las ejecuta asi:
> > Begin;
> > select funcion('resp_ref_cursor');
> > fecth all in "resp_ref_cursor";
> > commit;
> >
> > En cambio cuando es un afunción de tipo record como la ejecuto desde el query builder..
>
> select * from function( ... )
>
> Si es "setof record" entonces tienes que especificar el tipo del record:
>
> select * from function( ... ) as f(a int, b text, c text, ...)
>
> --
> Alvaro Herrera http://www.PlanetPostgreSQL.org/
> "I'm impressed how quickly you are fixing this obscure issue. I came from
> MS SQL and it would be hard for me to put into words how much of a better job
> you all are doing on [PostgreSQL]."
> Steve Midgley, http://archives.postgresql.org/pgsql-sql/2008-08/msg00000.php
> --
> TIP 3: Si encontraste la respuesta a tu problema, publícala, otros te lo agradecerán

_________________________________________________________________
Invite your mail contacts to join your friends list with Windows Live Spaces. It's easy!
http://spaces.live.com/spacesapi.aspx?wx_action=create&wx_url=/friends.aspx&mkt=en-us

In response to

Responses

Browse pgsql-es-ayuda by date

  From Date Subject
Next Message ALFONSO REYES 2008-12-09 01:33:36 RE: RE: Funciòn que devuelve un refcursor
Previous Message Fernando Hevia 2008-12-09 00:34:36 RE: hola... consulta de parametros de kernel.