Re: generic way to retrieve array as rowset

Поиск
Список
Период
Сортировка
От Volkan YAZICI
Тема Re: generic way to retrieve array as rowset
Дата
Msg-id 20060103144208.GA569@alamut
обсуждение исходный текст
Ответ на generic way to retrieve array as rowset  (SunWuKung <Balazs.Klein@axelero.hu>)
Ответы Re: generic way to retrieve array as rowset  ("A. Kretschmer" <andreas.kretschmer@schollglas.com>)
Список pgsql-general
Hi,

Here's a modified version of A. Kretschmer's answer. This one checks
array_upper() sizes and depending on it, doesn't provide unnecessary
NULL fields. HTH.

SELECT id, val[s.i]
FROM t7
LEFT JOIN
    (SELECT g.s
        FROM generate_series(1,
            (SELECT max(array_upper(val, 1)) FROM t7)) AS g(s)
    ) AS s(i)
    ON (s.i <= array_upper(val, 1));

Query is inspired by the pg_database_config view in newsysview.
(Thanks AndrewSN for pointing out the source.)


Regards.

On Jan 03 12:37, SunWuKung wrote:
> When storing data in an array, like this
>
> id    array
> 1,     {1,2}
> 2,     {10,20}
> 3,     {100,200}
>
> is there a generic way to retrieve them as arowset, like this
>
> id    array_dimension1
> 1    1
> 1     2
> 2     10
> 2     20
>
> By writing something like this:
>
> Select id, explode(array) From foo Where id<3

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

Предыдущее
От: Arnaud Lesauvage
Дата:
Сообщение: initdb: invalid locale name
Следующее
От: Andrew - Supernews
Дата:
Сообщение: Re: POSTGRES DB 3 800 000 rows table, speed up?