pg.ddx.io  pgsql-interfaces@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Rich Cullingford <rculling@sysd.com>
Cc: pgsql-interfaces@postgresql.org
Subject: Re: Assigning values to array components.
Date: Thu, 11 Sep 2003 17:08:59 -0400
Message-ID: <1480.1063314539@sss.pgh.pa.us> (raw)
In-Reply-To: <3F60D485.5030807@sysd.com>
References: <3F60D485.5030807@sysd.com>

Rich Cullingford <rculling@sysd.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



view thread (2+ messages)

Message-ID: <1480.1063314539@sss.pgh.pa.us>
Permalink:  ../1480.1063314539@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/1480.1063314539@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-interfaces@postgresql.org
  Cc: tgl@sss.pgh.pa.us, rculling@sysd.com
  Subject: Re: Assigning values to array components.
  In-Reply-To: <1480.1063314539@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox