Re: Assigning values to array components.

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Rich Cullingford <rculling(at)sysd(dot)com>
Cc: pgsql-interfaces(at)postgresql(dot)org
Subject: Re: Assigning values to array components.
Date: 2003-09-11 21:08:59
Message-ID: 1480.1063314539@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-interfaces

Rich Cullingford <rculling(at)sysd(dot)com> writes:
> create or replace function foobaz()
> RETURNS bigint[]
> AS '
> DECLARE
> answer bigint[];
> BEGIN
> answer[1] := 12345;
> RETURN answer;
> END;
> '
> LANGUAGE 'plpgsql';

> select foobaz();
> WARNING: plpgsql: ERROR during compile of foobaz near line 4
> ERROR: parse error at or near "["

IIRC, Joe Conway fixed that for 7.4. I can get your example to work
in CVS tip if I modify the DECLARE to

answer bigint[] = ''{}'';

Without that, you're trying to combine a NULL array with a nonnull
entry, which is going to give a NULL result.

regards, tom lane

In response to

Browse pgsql-interfaces by date

  From Date Subject
Next Message d=d=d 2003-09-12 07:33:39 couldn't open table
Previous Message Rich Cullingford 2003-09-11 20:01:09 Assigning values to array components.