Re: Retrieving multidimentional array-column using JDBC

From: Kris Jurka <books(at)ejurka(dot)com>
To: Andreas Joseph Krogh <andreak(at)officenet(dot)no>
Cc: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: Retrieving multidimentional array-column using JDBC
Date: 2010-03-10 18:12:00
Message-ID: alpine.BSO.2.00.1003101306580.29315@leary.csoft.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

On Wed, 10 Mar 2010, Andreas Joseph Krogh wrote:

> I have a query which returns a multidimentional array (2D) of varchar
> and I'm having problems retrieving the results using JDBC.
>
> First, since PG doesn't support arrays of arrays, I've created a custom
> type:

PG does support multidimensional arrays:

kjurka=# select array[array['a','b'],array['c','d']];
array
---------------
{{a,b},{c,d}}
(1 row)

You can then unnest these arrays according to the
testMultiDimensionalArray or testRecursiveResultSets examples here:

http://cvs.pgfoundry.org/cgi-bin/cvsweb.cgi/jdbc/pgjdbc/org/postgresql/test/jdbc2/ArrayTest.java?rev=1.19&content-type=text/x-cvsweb-markup

Kris Jurka

In response to

Responses

Browse pgsql-jdbc by date

  From Date Subject
Next Message Andreas Joseph Krogh 2010-03-10 18:20:33 Re: Retrieving multidimentional array-column using JDBC
Previous Message dmp 2010-03-10 17:30:08 Re: org.postgresql.util.PSQLException: Protocol error. Session setup failed