Re: Checking empty array

From: Richard Huxton <dev(at)archonet(dot)com>
To: Alexis Beuraud <alexis(at)siatel(dot)com>
Cc: "'pgsql-general(at)postgresql(dot)org'" <pgsql-general(at)postgresql(dot)org>
Subject: Re: Checking empty array
Date: 2007-10-30 10:32:11
Message-ID: 4727082B.6080405@archonet.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Pavel Stehule 2007-10-30 10:33:31 Re: Selecting K random rows - efficiently!
Previous Message Alexis Beuraud 2007-10-30 10:07:45 Checking empty array