Skip site navigation (1) Skip section navigation (2)

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 (view raw or flat)
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

pgsql-interfaces by date

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

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group