Re: Bidimensional Array

From: Kris Jurka <books(at)ejurka(dot)com>
To: Leandro Guimarães <leo(dot)guimaraes(at)gmail(dot)com>
Cc: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: Bidimensional Array
Date: 2011-12-26 20:41:52
Message-ID: 4EF8DC10.2020103@ejurka.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

On 12/26/2011 12:23 PM, Leandro Guimarães wrote:
> Hello Kris,
> thanks for your answer. The dataType is varchar.
>
> I did a workaround to solve the problem, but i'm sure it's not a good
> approach.
>
> I'm using the a1.toString() method and using .split by comma to break
> the value and return the String[]
>

Your problem is that you don't really have a two dimensional array. You
have a one dimensional array whose contents look similar to an array,
but are actually just a string of text.

jurka=# select array_ndims('{"{319.1,811.2,915.5}"}'::varchar[]);
array_ndims
-------------
1

Those interior quotes are not correct.

jurka=# select array_ndims('{{319.1,811.2,915.5}}'::varchar[]);
array_ndims
-------------
2

jurka=# select ('{{319.1,811.2,915.5}}'::varchar[])[1][1];
varchar
---------
319.1

Kris Jurka

In response to

Browse pgsql-jdbc by date

  From Date Subject
Next Message Maciek Sakrejda 2011-12-28 02:18:58 Re: test git conversion
Previous Message Kris Jurka 2011-12-26 20:06:50 Re: Bidimensional Array