Re: Checking empty array - Mailing list pgsql-general

From Richard Huxton
Subject Re: Checking empty array
Date
Msg-id 4727082B.6080405@archonet.com
Whole thread Raw
In response to Checking empty array  (Alexis Beuraud <alexis@siatel.com>)
List pgsql-general
Alexis Beuraud wrote:
> Dear all,
>
> What is the correct way to check whether an array is empty?

> -- Is my array empty now?
> IF (myarray isnull) THEN

An empty array isn't null (unknown), it's empty.

Try enquiring about it's size:
SELECT array_dims('{}'::integer[]) is null;
  ?column?
----------
  t

You could use array_lower/upper instead too.

--
   Richard Huxton
   Archonet Ltd

pgsql-general by date:

Previous
From: Alexis Beuraud
Date:
Subject: Checking empty array
Next
From: "Pavel Stehule"
Date:
Subject: Re: Selecting K random rows - efficiently!