Re: pl/pgsql array return

From: "Jose Luis LG" <jlopezgonz(at)terra(dot)es>
To: "'Barry Lind'" <barry(at)xythos(dot)com>
Cc: <pgsql-jdbc(at)postgresql(dot)org>
Subject: Re: pl/pgsql array return
Date: 2002-02-15 11:29:35
Message-ID: 01ed01c1b614$0dd86090$424d4d7d@Servidor2K.local
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

Thanks Barry,

I have tried this with no luck. I am very new pl/pgsql. I get a error
on the very first line of the function. The function is:

CREATE FUNCTION testFunction() RETURNS CURSOR AS '
....

Is this the correct way? Could you send me an example?

Thanks in advance

Jose Luis

> -----Original Message-----
> From: pgsql-jdbc-owner(at)postgresql(dot)org [mailto:pgsql-jdbc-
> owner(at)postgresql(dot)org] On Behalf Of Barry Lind
> Sent: miércoles, 13 de febrero de 2002 18:40
> To: Jose Luis LG
> Cc: pgsql-jdbc(at)postgresql(dot)org
> Subject: Re: [JDBC] pl/pgsql array return
>
> Jose,
>
> pl/pgsql can't return an array. However in 7.2 it can return a
cursor.
> So it is possible to do the following in jdbc:
>
> foo() is a pl/pgsql function that returns a cursor (see pl/pgsql doc
for
> 7.2 to see how this is done in pl/pgsql).
>
>
> ResultSet l_cursorRSet = dbcon.executeQuery("select foo()");
>
> l_cursorRSet.next();
> String l_cursor = l_cursorRSet.getString(1);
>
> ResultSet l_functionResults = dbcon.executeQuery("fetch all from " +
> l_cursor);
>
> while (l_functionResults.next()) {
> //do something useful with that data
> }
>
> //should close result sets and close the cursor when done
> ...
>
>
> thanks,
> --Barry
>
>
>
> Jose Luis LG wrote:
> > Hi,
> >
> >
> >
> > I hope someone can help me. Is it possible to return an array of
> > results from a query in a function in pl/pgsql and get this result
via
> > the jdbc. Could someone send me an example of how this is done.
> >
> >
> >
> >
> >
> > Thanks
> >
> >
> >
> > Jose Luis

In response to

Responses

Browse pgsql-jdbc by date

  From Date Subject
Next Message Tom Lane 2002-02-15 15:11:03 Re: BLOB files, Updates, ...
Previous Message Egon Sommer 2002-02-15 11:17:52 BLOB files, Updates, ... 2nd Edition