Search Postgresql Archives

Re: Arrays

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

 



On Wed, Sep 14, 2011 at 21:05, Fabrízio de Royes Mello
<fabriziomello@xxxxxxxxx> wrote:
> postgres@bdteste=# SELECT array_upper(ARRAY['foo', 'bar'], 1);

On Wed, Sep 14, 2011 at 21:09, Merlin Moncure <mmoncure@xxxxxxxxx> wrote:
> select count(*) from unnest(_array_);

On Wed, Sep 14, 2011 at 21:15, Steve Crawford
<scrawford@xxxxxxxxxxxxxxxxxxxx> wrote:
> Look at array_dims, array_upper and array_lower.

Huh, what's up with people suggesting overcomplicated solutions?

Just use the one function that's designed to do this: array_length(arr, 1)
Note that for an empty array, this will return NULL. If you want to
get 0 instead, use:
coalesce(array_length(arr, 1), 0)

Note that, for multidimensional arrays, this returns the length of the
1st dimension (hence 1 in arguments)

Regards,
Marti

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