Search Postgresql Archives

Re: Multi-dimensional arrays

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

 



On 15 March 2014 12:51, Raymond O'Donnell <rod@xxxxxx> wrote:
> Hello all,
>
> Here's an odd one (to me anyway) which I ran into today.... if I have a
> multidimensional array, why does the following return NULL?
>
>     select (array[['abc','def'], ['ghi','jkl']])[1]
>
> I would have expected it to return {abc, def}. This, however, returns
> 'abc' as expected:
>
>     select (array[['abc','def'], ['ghi','jkl']])[1][1]

Hmm... I'm not sure.  You can get to it with slices for some reason:

#  select (array[['abc','def'], ['ghi','jkl']])[0:1];
    array
-------------
 {{abc,def}}
(1 row)

# select (array[['abc','def'], ['ghi','jkl']])[1:2];
         array
-----------------------
 {{abc,def},{ghi,jkl}}
(1 row)

# select (array[['abc','def'], ['ghi','jkl']])[2:3];
    array
-------------
 {{ghi,jkl}}
(1 row)

-- 
Thom


-- 
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