Re: [Q] parsing out String array

Поиск
Список
Период
Сортировка
От Sam Mason
Тема Re: [Q] parsing out String array
Дата
Msg-id 20090816110607.GU5407@samason.me.uk
обсуждение исходный текст
Ответ на Re: [Q] parsing out String array  (toreason@fastmail.fm)
Список pgsql-general
On Sun, Aug 16, 2009 at 05:55:08AM -0400, toreason@fastmail.fm wrote:
> Thank you for your recommendation
> I was able to get this to work
>
> select ('{{A,B,C},{D,E,F}}'::text[][])[i][j] from
>   generate_series(1, array_upper('{{A,B,C},{D,E,F}}'::text[][], 1)) i
>   cross join
>   generate_series(1, array_upper('{{A,B,C},{D,E,F}}'::text[][], 2)) j

I've just noticed that you mentioned using 8.4 previously; there's a new
function called unnest in 8.4 that does the above.  In your example it
would be:

  SELECT unnest('{{A,B,C},{D,E,F}}'::text[]);

and you'd get back your six rows.  It appears to do the correct thing
with arrays of higher dimensionality to me, but I only tried up to five.

--
  Sam  http://samason.me.uk/

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

Предыдущее
От: toreason@fastmail.fm
Дата:
Сообщение: Re: [Q] parsing out String array
Следующее
От: Thom Brown
Дата:
Сообщение: Generating random unique alphanumeric IDs