Re: Arrays

Поиск
Список
Период
Сортировка
От Marti Raudsepp
Тема Re: Arrays
Дата
Msg-id CABRT9RBDRgPYRvpek44EVH1-+efnVoGHVCKJ-mzD=S5idEPfKA@mail.gmail.com
обсуждение исходный текст
Ответ на Re: Arrays  (Steve Crawford <scrawford@pinpointresearch.com>)
Список pgsql-general
On Wed, Sep 14, 2011 at 21:05, Fabrízio de Royes Mello
<fabriziomello@gmail.com> wrote:
> postgres@bdteste=# SELECT array_upper(ARRAY['foo', 'bar'], 1);

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

On Wed, Sep 14, 2011 at 21:15, Steve Crawford
<scrawford@pinpointresearch.com> 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

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

Предыдущее
От: Adrian Klaver
Дата:
Сообщение: Re: RES: Foreign PostgreSQL server
Следующее
От: Andy Colson
Дата:
Сообщение: Re: Apparent Problem With NULL in Restoring pg_dump