Re: how can I select into an array?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Andy Kriger" <akriger(at)greaterthanone(dot)com>
Cc: "Pgsql-General" <pgsql-general(at)postgresql(dot)org>
Subject: Re: how can I select into an array?
Date: 2004-02-06 17:08:16
Message-ID: 1213.1076087296@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

"Andy Kriger" <akriger(at)greaterthanone(dot)com> writes:
> I would like to select strings from a table and return them as an array

You can do that beginning in 7.4 with the ARRAY(sub-select) construct.

regression=# select f1 from text_tbl;
f1
-------------------
doh!
hi de ho neighbor
(2 rows)

regression=# select array(select f1 from text_tbl);
?column?
----------------------------
{doh!,"hi de ho neighbor"}
(1 row)

regression=#

In prior versions you could probably fake it with a loop in a plpgsql
function, but it'd be kinda awkward.

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Joe Conway 2004-02-06 17:14:36 Re: how can I select into an array?
Previous Message Tom Lane 2004-02-06 17:04:49 Re: Run 2 versions of Postgresql on one machine?