CSN <cool_screen_name90001@yahoo.com> 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