From: | "Pavel Stehule" <pavel(dot)stehule(at)gmail(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:37:24 |
Message-ID: | 162867790710300337m6a998330y1ecf56766d492be5@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
2007/10/30, Alexis Beuraud <alexis(at)siatel(dot)com>:
> 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;
>
IF (array_upper(myarray,1) is null) THEN
....
END IF;
Regards
Pavel Stehule
> Regards,
> Alexis Beuraud
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 1: if posting/reading through Usenet, please send an appropriate
> subscribe-nomail command to majordomo(at)postgresql(dot)org so that your
> message can get through to the mailing list cleanly
>
From | Date | Subject | |
---|---|---|---|
Next Message | Catalin Marinas | 2007-10-30 10:41:27 | Re: Fragments in tsearch2 headline |
Previous Message | Pavel Stehule | 2007-10-30 10:33:31 | Re: Selecting K random rows - efficiently! |