Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 4A2F3475F1A for ; Fri, 27 Sep 2002 12:04:49 -0400 (EDT) Received: from davinci.ethosmedia.com (davinci.ethosmedia.com [209.10.40.250]) by postgresql.org (Postfix) with ESMTP id B62F8475E2E for ; Fri, 27 Sep 2002 12:04:48 -0400 (EDT) Received: from [63.195.55.98] (account ) by davinci.ethosmedia.com (CommuniGate Pro WebUser 3.5.9) with HTTP id 1731886; Fri, 27 Sep 2002 09:04:58 -0700 From: "Josh Berkus" Subject: Re: Passing array to PL/SQL and looping To: Greg Johnson , Josh Berkus , pgsql-sql@postgresql.org X-Mailer: CommuniGate Pro Web Mailer v.3.5.9 Date: Fri, 27 Sep 2002 09:04:58 -0700 Message-ID: In-Reply-To: <1033140741.4254.12.camel@watto.interprose.net> MIME-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 8bit X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200209/380 X-Sequence-Number: 9657 Greg, > CREATE FUNCTION test_array( ) RETURNS VARCHAR[] AS ' > DECLARE > return_array VARCHAR[]; > BEGIN > return_array[0] := ''test''; > return_array[1] := ''test 1''; > return_array[2] := ''test 2''; > RETURN (return_array); > END;' > LANGUAGE 'plpgsql'; No, it's not possible to do the above. This is a flaw in the current implementation of PL/pgSQL that will not be resolved until we attract some new Postgres hackers who really care about upgrading PL/pgSQL. Currently, if you want to use an array, it has to be passed as a parameter, or come from an external table. You cannot declare an Array data type. Annoying, really. -Josh Berkus