Received: from maia.hub.org (unknown [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id F1862633FF7 for ; Wed, 10 Mar 2010 14:22:39 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 75816-05-3 for ; Wed, 10 Mar 2010 18:22:29 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from ns1.officenet.no (unknown [195.159.87.244]) by mail.postgresql.org (Postfix) with ESMTP id 0FBBC635979 for ; Wed, 10 Mar 2010 14:22:20 -0400 (AST) Received: from [88.88.37.27] (helo=andreak-laptop.localnet) by ns1.officenet.no with esmtpsa (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.69) (envelope-from ) id 1NpQXs-0005G0-6b for pgsql-jdbc@postgresql.org; Wed, 10 Mar 2010 19:22:17 +0100 From: Andreas Joseph Krogh Organization: OfficeNet AS To: pgsql-jdbc@postgresql.org Subject: Re: Retrieving multidimentional array-column using JDBC Date: Wed, 10 Mar 2010 19:20:33 +0100 User-Agent: KMail/1.13.1 (Linux/2.6.31-20-generic; KDE/4.4.1; i686; ; ) References: <201003100039.14562.andreak@officenet.no> In-Reply-To: MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Message-Id: <201003101920.34508.andreak@officenet.no> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-0.64 tagged_above=-10 required=5 tests=BAYES_20=-0.74, RDNS_NONE=0.1 X-Spam-Level: X-Archive-Number: 201003/35 X-Sequence-Number: 20375 On Wednesday 10. March 2010 19.12.00 Kris Jurka wrote: >=20 > On Wed, 10 Mar 2010, Andreas Joseph Krogh wrote: >=20 > > I have a query which returns a multidimentional array (2D) of varchar=20 > > and I'm having problems retrieving the results using JDBC. > > > > First, since PG doesn't support arrays of arrays, I've created a custom= =20 > > type: >=20 > PG does support multidimensional arrays: >=20 > kjurka=3D# select array[array['a','b'],array['c','d']]; > array > --------------- > {{a,b},{c,d}} > (1 row) Yes, I know it works using the array[...] construct, but it doesn't work (a= t least I don't know how to make it work) when the ARRAY()-construct is use= d to create an array of a sub-select returning rows of varchar-array. If you see the example-query I sent, do you have any suggestion on how to r= ewrite it in order to make it return an array of varchar-arrays without usi= ng the custom-type text_array? This query (using the ARRAY()-construct) fails: SELECT act.id,=20 ARRAY(SELECT ARRAY( WITH RECURSIVE parent(level, id, p_id, element) AS( SELECT 1, pw.id, pw.p_id, pw.element UNION ALL SELECT rec.level + 1, pw_.id, pw_.p_id, pw_.element=20 FROM pathway pw_, parent rec WHERE pw_.id =3D rec.p_id ) SELECT element FROM parent ORDER BY level DESC ) AS pathway_array FROM pathway pw, path_usage pu WHERE pu.foo_id =3D act.id AND pu.pathway_id =3D pw.id ORDER BY lower(pw.element) ASC ) as pathway_array =46ROM foo act ; ERROR: could not find array type for data type character varying[] Hints? =2D-=20 Andreas Joseph Krogh Senior Software Developer / CTO =2D-----------------------+---------------------------------------------+ OfficeNet AS | The most difficult thing in the world is to | Rosenholmveien 25 | know how to do a thing and to watch | 1414 Troll=E5sen | somebody else doing it wrong, without | NORWAY | comment. | | | Tlf: +47 24 15 38 90 | | =46ax: +47 24 15 38 91 | | Mobile: +47 909 56 963 | | =2D-----------------------+---------------------------------------------+