pg.ddx.io pgsql-jdbc@postgresql.org mailing list archive
help / color / mirror / Atom feedBidimensional Array
3+ messages / 2 participants
[nested] [flat]
* Bidimensional Array
@ 2011-12-26 18:08 Leandro Guimarães <leo.guimaraes@gmail.com>
2011-12-26 20:06 ` Re: Bidimensional Array Kris Jurka <books@ejurka.com>
0 siblings, 1 reply; 3+ messages in thread
From: Leandro Guimarães @ 2011-12-26 18:08 UTC (permalink / raw)
To: pgsql-jdbc
Hello Everyone,
Please, could someone help me with the following problem?
I need to get a bidimensional array from a postgresql function,
everything is working fine with the driver version 8.2 bellow, put when i
upgraded to 9.x the .getArray() method is not working anymore, i always
have the message: No *results* were *returned* by the *query.
Following my code and my exception with the comments, please i'm crazy
searching for a answer for this problem:
*
....
Array arr = rs.getArray(1); //checking the array, i'ts possible to see the
elements "{"{319.1,811.2,915.5}"}"
ResultSet arrRS = arr.getResultSet();
while (arrRS.next()) {
Array a1 = arrRS.getArray(2); //checking the array, i'ts possible to
see the elements {319.1,811.2,915.5}
String[] str = (String[]) a1.getArray(); //HERE HAPPENS THE EXCEPTION
}
...
Following the exception
rg.postgresql.util.PSQLException: No *results* were *returned* by the *
query.*
at
org.postgresql.jdbc2.TypeInfoCache.getPGArrayElement(TypeInfoCache.java:390)
at
org.postgresql.jdbc2.AbstractJdbc2Array.buildArray(AbstractJdbc2Array.java:323)
at
org.postgresql.jdbc2.AbstractJdbc2Array.getArrayImpl(AbstractJdbc2Array.java:149)
at
org.postgresql.jdbc2.AbstractJdbc2Array.getArray(AbstractJdbc2Array.java:115)
Thanks!
Leandro Guimarães
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: Bidimensional Array
2011-12-26 18:08 Bidimensional Array Leandro Guimarães <leo.guimaraes@gmail.com>
@ 2011-12-26 20:06 ` Kris Jurka <books@ejurka.com>
2011-12-26 20:41 ` Re: Bidimensional Array Kris Jurka <books@ejurka.com>
0 siblings, 1 reply; 3+ messages in thread
From: Kris Jurka @ 2011-12-26 20:06 UTC (permalink / raw)
To: Leandro Guimarães <leo.guimaraes@gmail.com>; +Cc: pgsql-jdbc
On Mon, 26 Dec 2011, Leandro Guimar?es wrote:
> I need to get a bidimensional array from a postgresql function, everything
> is working fine with the driver version 8.2 bellow, put when i upgraded to
> 9.x the .getArray() method is not working anymore, i always have the
> message: No results were returned by the query.
>
What is the datatype of the column?
Kris Jurka
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: Bidimensional Array
2011-12-26 18:08 Bidimensional Array Leandro Guimarães <leo.guimaraes@gmail.com>
2011-12-26 20:06 ` Re: Bidimensional Array Kris Jurka <books@ejurka.com>
@ 2011-12-26 20:41 ` Kris Jurka <books@ejurka.com>
0 siblings, 0 replies; 3+ messages in thread
From: Kris Jurka @ 2011-12-26 20:41 UTC (permalink / raw)
To: Leandro Guimarães <leo.guimaraes@gmail.com>; +Cc: 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
^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2011-12-26 20:41 UTC | newest]
Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2011-12-26 18:08 Bidimensional Array Leandro Guimarães <leo.guimaraes@gmail.com>
2011-12-26 20:06 ` Kris Jurka <books@ejurka.com>
2011-12-26 20:41 ` Kris Jurka <books@ejurka.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox