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

From CSN
Subject Re: Declaring empty, non-NULL array in plpgsql
Date
Msg-id 20031124052625.31981.qmail@web40604.mail.yahoo.com
Whole thread Raw
In response to Declaring empty, non-NULL array in plpgsql  (CSN <cool_screen_name90001@yahoo.com>)
Responses Re: Declaring empty, non-NULL array in plpgsql  (Joe Conway <mail@joeconway.com>)
List pgsql-general
This avoids the NULL problem - is there a better way?

    aCats varchar[] = array[''''];
    vCats varchar;
    iIndex int := 1;
    rItem record;

    ...

    for rItem in select ... loop
        aCats[iIndex] := rItem.name;

        iIndex := iIndex + 1;
    end loop;

    vCats := array_to_string(aCats, '','');
    ...



--- CSN <cool_screen_name90001@yahoo.com> wrote:
> Is there a way to declare an array in plpgsql so
> that
> it's empty (not NULL)? The following causes arr to
> end
> up being NULL:
>
> arr varchar[];
> -- do stuff with arr..
> arr = array_append(arr, '','');
>
>
> And this causes an unwanted element at the front:
>
> arr varchar[] := array[''''];
> -- do stuff with arr..
> arr = array_append(arr, '','');
>
>
> __________________________________
> Do you Yahoo!?
> Free Pop-Up Blocker - Get it now
> http://companion.yahoo.com/
>


__________________________________
Do you Yahoo!?
Free Pop-Up Blocker - Get it now
http://companion.yahoo.com/

pgsql-general by date:

Previous
From: CSN
Date:
Subject: Declaring empty, non-NULL array in plpgsql
Next
From: Joe Conway
Date:
Subject: Re: Declaring empty, non-NULL array in plpgsql