pg.ddx.io  pgsql-interfaces@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Rich Cullingford <rculling@sysd.com>
To: pgsql-interfaces@postgresql.org
Subject: Assigning values to array components.
Date: Thu, 11 Sep 2003 16:01:09 -0400
Message-ID: <3F60D485.5030807@sysd.com> (raw)

Hello All,
I have a small application (based on sorting inet[] arrays) that 
requires building an array of bigints, one for each inet in the array. 
This is doable in most programming languages with a notation like:

      inet_bigints[i] := inet2bigint(ip)

Unfortunately, plpgsql doesn't seem to allow that kind of assignment, as 
loading the following into psql reveals:

create or replace function foobaz()
RETURNS bigint[]
AS '
DECLARE
     answer bigint[];
BEGIN
   answer[1] := 12345;
   RETURN answer;
END;
'
LANGUAGE 'plpgsql';

When I try to run this:

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

The system also won't let me initialize the array in the DECLARE 
section. I've looked through the archives for the past few years for 
hints about this, but haven't found anything. Is there a plpgsql 
reference that's more 'complete' than the one that comes with the PG 
distribution?

Any help greatly appreciated.
                                Rich Cullingford
                                rculling@sysd.com




view thread (2+ messages)  latest in thread

Message-ID: <3F60D485.5030807@sysd.com>
Permalink:  ../3F60D485.5030807@sysd.com/
Also on:    postgresql.org/message-id/3F60D485.5030807@sysd.com

 · 

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: rculling@sysd.com
  Subject: Re: Assigning values to array components.
  In-Reply-To: <3F60D485.5030807@sysd.com>

* 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