From: | "Pavel Stehule" <pavel(dot)stehule(at)gmail(dot)com> |
---|---|
To: | pgsql-sql(at)postgresql(dot)org |
Subject: | Re: returning an array as a list fo single-column rows? |
Date: | 2007-12-23 21:19:26 |
Message-ID: | 162867790712231319i35fb31el8d4c367bc313979b@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
Hello
try
create or replace function unpack(anyarray)
returns setof anyelement as $$
select $1[i]
from generate_series(array_lower($1,1), array_upper($1,1)) g(i);
$$ language sql;
postgres=# select * from unpack(array[1,2,3,4]);
unpack
--------
1
2
3
4
(4 rows)
Regards
Pavel Stehule
On 23/12/2007, Louis-David Mitterrand
<vindex+lists-pgsql-sql(at)apartia(dot)org> wrote:
> Hi,
>
> is there a way to return a Pg array as a list of single-column row
> values?
>
> I am trying to circumvent DBI's lack of support for native database
> arrays and return the list of values from an ENUM as a perl array.
>
> Thanks,
>
> ---------------------------(end of broadcast)---------------------------
> TIP 7: You can help support the PostgreSQL project by donating at
>
> http://www.postgresql.org/about/donate
>
From | Date | Subject | |
---|---|---|---|
Next Message | Louis-David Mitterrand | 2007-12-23 21:22:05 | Re: returning an array as a list fo single-column rows? |
Previous Message | Louis-David Mitterrand | 2007-12-23 20:55:57 | returning an array as a list fo single-column rows? |