Skip site navigation (1) Skip section navigation (2)

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 (view raw or flat)
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

pgsql-jdbc by date

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

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group