CSN <[EMAIL PROTECTED]> writes:
> Is there a way to declare an array in plpgsql so that
> it's empty (not NULL)?

Sure.  An empty-array literal is '{}', so:

regression=# create function foo(int) returns varchar[] as '
regression'# declare
regression'#   arr varchar[] := ''{}'';
regression'# begin
regression'#   for i in 1..$1 loop
regression'#     arr = array_append(arr, i::varchar);
regression'#   end loop;
regression'# return arr;
regression'# end' language plpgsql;
CREATE FUNCTION
regression=# select foo(10);
          foo
------------------------
 {1,2,3,4,5,6,7,8,9,10}
(1 row)


                        regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
    (send "unregister YourEmailAddressHere" to [EMAIL PROTECTED])

Reply via email to