Re: Declaring empty, non-NULL array in plpgsql - Mailing list pgsql-general

From Joe Conway
Subject Re: Declaring empty, non-NULL array in plpgsql
Date
Msg-id 3FC19AE6.1050007@joeconway.com
Whole thread Raw
In response to Re: Declaring empty, non-NULL array in plpgsql  (CSN <cool_screen_name90001@yahoo.com>)
List 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 by date:

Previous
From: CSN
Date:
Subject: Re: Declaring empty, non-NULL array in plpgsql
Next
From: "LitelWang"
Date:
Subject: what's the compile option for the postgresql 7.3 in redhat 9 ?