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

Поиск
Список
Период
Сортировка
От Louis-David Mitterrand
Тема Re: returning an array as a list fo single-column rows?
Дата
Msg-id 20071223213345.GA15623@apartia.fr
обсуждение исходный текст
Ответ на Re: returning an array as a list fo single-column rows?  ("Pavel Stehule" <pavel.stehule@gmail.com>)
Ответы Re: returning an array as a list fo single-column rows?
Список pgsql-sql
On Sun, Dec 23, 2007 at 10:27:09PM +0100, Pavel Stehule wrote:
> On 23/12/2007, Louis-David Mitterrand
> <vindex+lists-pgsql-sql@apartia.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@localhost ~]$ perl
> @a = split(/\|/, "1|2|3");
> print $a[1];

Yes I thought about it, but would rather have Pg do the array splitting. 
For instance if the separator occurs in an array element there is no 
built-in escaping:

% select array_to_string(array['ee','dd','rr','f|f'],'|');array_to_string ----------------- ee|dd|rr|f|f

... and then perl would have it all wrong.


В списке pgsql-sql по дате отправления:

Предыдущее
От: "Pavel Stehule"
Дата:
Сообщение: Re: returning an array as a list fo single-column rows?
Следующее
От: "Pavel Stehule"
Дата:
Сообщение: Re: returning an array as a list fo single-column rows?