X-Original-To: pgsql-interfaces-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id CC0AED1B52C for ; Thu, 11 Sep 2003 20:01:49 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 03279-06 for ; Thu, 11 Sep 2003 17:01:19 -0300 (ADT) Received: from martin.sysdetect.com (martin.sysdetect.com [65.209.102.1]) by svr1.postgresql.org (Postfix) with ESMTP id 4A7ADD1B579 for ; Thu, 11 Sep 2003 17:01:16 -0300 (ADT) Received: (from mail@localhost) by martin.sysdetect.com (8.11.4/8.11.3) id h8BK1EQ09060 for ; Thu, 11 Sep 2003 20:01:14 GMT Received: from winwood.sysdetect.com(172.16.1.1) via SMTP by mail.sysdetect.com, id smtpdw22956; Thu Sep 11 20:01:10 2003 Received: from sysd.com (thriller.sysdetect.com [172.16.1.33]) by winwood.sysdetect.com (8.11.6/8.11.6) with ESMTP id h8BK19b26587 for ; Thu, 11 Sep 2003 16:01:09 -0400 Message-ID: <3F60D485.5030807@sysd.com> Date: Thu, 11 Sep 2003 16:01:09 -0400 From: Rich Cullingford User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.3) Gecko/20030314 X-Accept-Language: en-us, en MIME-Version: 1.0 To: pgsql-interfaces@postgresql.org Subject: Assigning values to array components. Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200309/18 X-Sequence-Number: 4436 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