Re: cursores en procedimientos almacenados

From: Jaime Casanova <systemguards(at)gmail(dot)com>
To: Frank Jonislla <frank(dot)che88(at)gmail(dot)com>
Cc: pgsql-es-ayuda(at)postgresql(dot)org
Subject: Re: cursores en procedimientos almacenados
Date: 2006-02-19 05:45:05
Message-ID: c2d9e70e0602182145w49369944i209b1a205ccf3e02@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-es-ayuda

On 2/17/06, Frank Jonislla <frank(dot)che88(at)gmail(dot)com> wrote:
> Tengo dos funciones que devuelven cursores que practicamente son lo mismo
> pero solo uno funciona cuando lo llamo a travez de una palicacio hecha en
> punto .net
>
> bueno estas son las dos funciones:
>
> CREATE OR REPLACE FUNCTION testrefcursor()
>
> RETURNS SETOF refcursor AS
>
> $BODY$
>
> DECLARE
>
> ref1 refcursor;
>
> ref2 refcursor;
>
> BEGIN
>
> OPEN ref1 FOR SELECT * FROM Clientes;
>
> RETURN NEXT ref1;
>
> OPEN ref2 FOR SELECT * FROM Pedidos;
>
> RETURN next ref2;
>
> RETURN;
>
> END;$BODY$
>
> LANGUAGE 'plpgsql' VOLATILE;
>
[...snip...]
>
> Unhandled Exception: System.IndexOutOfRangeException: Column index out of
> range
> at Npgsql.NpgsqlDataReader.GetValue(Int32 Index)
> at pruebaCursor.c.Main(String[] args) in d:\Documents and
> Settings\mireya\Mis
> documentos\SharpDevelop Projects\pruebaCursor\Main.cs:line 41

AFAIK, no puedes regresar dos cursores distintos en una funcion plpgsql...

segun yo lo entiendo, aunque puedo estar equivocado porque nunca lo he
hecho, el que te este funcionando la primera es lo que esta mal...

se me ocurre que
quiza el cursor de clientes tiene menos columnas que el cursor de
pedidos y por eso le permite pasar... quiza en la segunda funcion el
cursor de clientes tiene mas columnas que el de paises y entonces se
da cuenta y te manda el error...

--
Atentamente,
Jaime Casanova

"What they (MySQL) lose in usability, they gain back in benchmarks, and that's
all that matters: getting the wrong answer really fast."
Randal L. Schwartz

In response to

Browse pgsql-es-ayuda by date

  From Date Subject
Next Message Miguel Angel 2006-02-19 22:21:52 Significado
Previous Message Jaime Casanova 2006-02-19 05:27:37 Re: ayuda..