Re: [Q] parsing out String array - Mailing list pgsql-general

From Sam Mason
Subject Re: [Q] parsing out String array
Date
Msg-id 20090816110607.GU5407@samason.me.uk
Whole thread Raw
In response to Re: [Q] parsing out String array  (toreason@fastmail.fm)
List 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 by date:

Previous
From: toreason@fastmail.fm
Date:
Subject: Re: [Q] parsing out String array
Next
From: Thom Brown
Date:
Subject: Generating random unique alphanumeric IDs