Search Postgresql Archives

Re: [Q] parsing out String array

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sun, Aug 16, 2009 at 05:55:08AM -0400, toreason@xxxxxxxxxxx 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/

-- 
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux