Checking empty array

Поиск
Список
Период
Сортировка
От Alexis Beuraud
Тема Checking empty array
Дата
Msg-id 20071030100749.71C879FB582@postgresql.org
обсуждение исходный текст
Ответы Re: Checking empty array  (Richard Huxton <dev@archonet.com>)
Re: Checking empty array  ("Pavel Stehule" <pavel.stehule@gmail.com>)
Re: Checking empty array  ("Albe Laurenz" <laurenz.albe@wien.gv.at>)
Список pgsql-general
Dear all,

What is the correct way to check whether an array is empty?
I have an array which I initialize with '{}' and then do som array_append
under some circonstances. I would like to know whether the array is empty at
the end of the function. I have not found the answer in the help page nor on
the web. I use the keyword isnull but that does not seem to work in all the
cases.
I would appreciate if someone could put this piece of information into the
Postgres documentation.

Here is what I do, in pseudo-code:

myarray varchar[];
myarray :=   '{}';

FOR ___ LOOP
 IF (___) THEN
    myarray := array_append(myarray, somestuff);
 END IF;
END LOOP;

-- Is my array empty now?
IF (myarray isnull) THEN
__
END IF;

Regards,
Alexis Beuraud


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

Предыдущее
От: "vincent"
Дата:
Сообщение: Re: Selecting K random rows - efficiently!
Следующее
От: Richard Huxton
Дата:
Сообщение: Re: Checking empty array