Re: Declaring empty, non-NULL array in plpgsql

Поиск
Список
Период
Сортировка
От Joe Conway
Тема Re: Declaring empty, non-NULL array in plpgsql
Дата
Msg-id 3FC19AE6.1050007@joeconway.com
обсуждение исходный текст
Ответ на Re: Declaring empty, non-NULL array in plpgsql  (CSN <cool_screen_name90001@yahoo.com>)
Список pgsql-general
CSN wrote:
> This avoids the NULL problem - is there a better way?
>
>     aCats varchar[] = array[''''];

aCats varchar[] = ''{}'';

This gives you a truly empty array that can later become single or
multidimensional.

e.g.

regression=# select '{}'::int[] || 1;
  ?column?
----------
  {1}
(1 row)

regression=# select '{}'::int[] || array[1,2];
  ?column?
----------
  {1,2}
(1 row)

regression=# select '{}'::int[] || array[[1,2],[3,4]];
    ?column?
---------------
  {{1,2},{3,4}}
(1 row)

HTH,

Joe


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

Предыдущее
От: CSN
Дата:
Сообщение: Re: Declaring empty, non-NULL array in plpgsql
Следующее
От: "LitelWang"
Дата:
Сообщение: what's the compile option for the postgresql 7.3 in redhat 9 ?