Received: from maia.hub.org (unknown [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id E219D632DA5 for ; Mon, 6 Jul 2009 21:36:40 -0300 (ADT) 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 60927-08 for ; Mon, 6 Jul 2009 21:36:37 -0300 (ADT) X-Greylist: delayed 00:22:17.571215 by SQLgrey-1.7.6 Received: from ns1.officenet.no (unknown [195.159.87.244]) by mail.postgresql.org (Postfix) with ESMTP id 72D8A632870 for ; Mon, 6 Jul 2009 21:36:37 -0300 (ADT) Received: from [77.106.167.81] (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 1MNyK2-0002bS-Q4 for pgsql-jdbc@postgresql.org; Tue, 07 Jul 2009 02:14:16 +0200 From: Andreas Joseph Krogh Organization: OfficeNet AS To: pgsql-jdbc@postgresql.org Subject: Retrieving results from ARRAY and ROW Date: Tue, 7 Jul 2009 02:14:00 +0200 User-Agent: KMail/1.12.0 (Linux/2.6.28-13-generic; KDE/4.2.95; i686; ; ) MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <200907070214.01001.andreak@officenet.no> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.1 tagged_above=0 required=5 tests=RDNS_NONE=0.1 X-Spam-Level: X-Archive-Number: 200907/13 X-Sequence-Number: 19781 Hi all! (Using pg-8.4 with postgresql-8.4-701.jdbc4.jar) I have the following (simplified for example) schema: CREATE TABLE person(id INTEGER, name VARCHAR); INSERT INTO person(id, name)=20 VALUES (1,'James'),(2, 'Jack'); CREATE TABLE person_dep(person_id INTEGER, dep VARCHAR); INSERT INTO person_dep(person_id, dep)=20 VALUES (1,'Dep1'),(1,'Dep2'); SELECT p.id, p.name , ARRAY(SELECT ROW(dep.person_id, dep.dep) FROM person_dep dep WHERE dep.person_id =3D p.id) AS my_array FROM person p WHERE p.id IN (1,2); id | name | my_array =2D---+-------+------------------------- 1 | James | {"(1,Dep1)","(1,Dep2)"} 2 | Jack | {} (2 rows) The problem is that I'm not able to retrieve the results from "my_array" us= ing rs.getArray("my_array").getArray(), which results in: org.postgresql.util.PSQLException: Method org.postgresql.jdbc4.Jdbc4Array.g= etArrayImpl(long,int,Map) is not yet implemented. Does someone know any better way to write this query which makes it work wi= th JDBC? I know I can write 2 sub-selects instead of one and have each colu= mn return and array of integer[] and varchar[], but I'm trying to avoid hav= ing more than *one* sub-select. My actual query involves a "WITH RECURSIVE" sub-select which retrieves pairs for the parent of each node to form a path up to the top-most p= arent, which makes several sub-selects involving CTE unattractive. =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=C3=A5sen | 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-----------------------+---------------------------------------------+