Re: returning an array as a list fo single-column rows?

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:27:09
Message-ID: 162867790712231327g774b8c5ld488113a3a8252e9@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

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

you can solve this problem with conversion to string with const separator

Like:

postgres=# select array_to_string(array[1,2,3,4],'|');
array_to_string
-----------------
1|2|3|4
(1 row)

[pavel(at)localhost ~]$ perl
@a = split(/\|/, "1|2|3");
print $a[1];

Regards
Pavel

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Louis-David Mitterrand 2007-12-23 21:33:45 Re: returning an array as a list fo single-column rows?
Previous Message Louis-David Mitterrand 2007-12-23 21:22:05 Re: returning an array as a list fo single-column rows?