Re: pl/pgsql array return

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Dave(at)micro-automation(dot)net
Cc: "'Jose Luis LG'" <jlopezgonz(at)terra(dot)es>, pgsql-jdbc(at)postgresql(dot)org
Subject: Re: pl/pgsql array return
Date: 2002-02-13 16:26:58
Message-ID: 29080.1013617618@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

> 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.

You can return an array value from plpgsql, no problem. The problem is
that plpgsql is pretty weak on functionality for constructing an array
value on the fly. I think the only way that would work is to build up
a textual representation of an array literal ('{foo,bar,baz}') and then
rely on runtime type conversion to do the right thing when you try to
RETURN the text string from a function declared as returning int[] or
whatever.

You might have better luck doing this in pltcl or plperl, either of
which have string-mashing facilities far superior to plpgsql.

regards, tom lane

In response to

Browse pgsql-jdbc by date

  From Date Subject
Next Message Nick Fankhauser 2002-02-13 17:04:09 Re: problem with storing BLOBs larger then 2MB
Previous Message Peter V. Cooper 2002-02-13 15:57:15 Re: problem with storing BLOBs larger then 2MB