pg.ddx.io pgsql-jdbc@postgresql.org mailing list archive
help / color / mirror / Atom feedArray of box not supported?
3+ messages / 2 participants
[nested] [flat]
* Array of box not supported?
@ 2011-02-16 16:25 RW Shore <rws228@gmail.com>
0 siblings, 1 reply; 3+ messages in thread
From: RW Shore @ 2011-02-16 16:25 UTC (permalink / raw)
To: pgsql-jdbc
To insert into a box[ ], I need to convert the individual boxes into a
string. I get a "malformed array literal" error with any of the following
formats for a 1 dimensional array with two boxes:
{"1.0,1.0,0.0,0.0","10.0,10.0,0.0,0.0"}
{"((1.0,1.0),(0.0,0.0))","((10.0,10.0),(0.0,0.0))"}
{"(1.0,1.0),(0.0,0.0)","(10.0,10.0),(0.0,0.0)"}
Can anybody suggest other things to try, or do I conclude that box[ ] isn't
supported?
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: Array of box not supported?
@ 2011-02-16 17:17 Tom Lane <tgl@sss.pgh.pa.us>
parent: RW Shore <rws228@gmail.com>
0 siblings, 1 reply; 3+ messages in thread
From: Tom Lane @ 2011-02-16 17:17 UTC (permalink / raw)
To: RW Shore <rws228@gmail.com>; +Cc: pgsql-jdbc
RW Shore <rws228@gmail.com> writes:
> To insert into a box[ ], I need to convert the individual boxes into a
> string. I get a "malformed array literal" error with any of the following
> formats for a 1 dimensional array with two boxes:
> {"1.0,1.0,0.0,0.0","10.0,10.0,0.0,0.0"}
> {"((1.0,1.0),(0.0,0.0))","((10.0,10.0),(0.0,0.0))"}
> {"(1.0,1.0),(0.0,0.0)","(10.0,10.0),(0.0,0.0)"}
For historical reasons (well, I can see why they did it, but it's still
weird), array of box uses semicolon not comma as the delimiter between
array elements.
regression=# select '{"1.0,1.0,0.0,0.0","10.0,10.0,0.0,0.0"}'::box[];
ERROR: malformed array literal: "{"1.0,1.0,0.0,0.0","10.0,10.0,0.0,0.0"}"
LINE 1: select '{"1.0,1.0,0.0,0.0","10.0,10.0,0.0,0.0"}'::box[];
^
regression=# select '{"1.0,1.0,0.0,0.0";"10.0,10.0,0.0,0.0"}'::box[];
box
-----------------------------
{(1,1),(0,0);(10,10),(0,0)}
(1 row)
The advantage is you don't need double quotes:
regression=# select '{1.0,1.0,0.0,0.0;10.0,10.0,0.0,0.0}'::box[];
box
-----------------------------
{(1,1),(0,0);(10,10),(0,0)}
(1 row)
Whether this requires any special pushups on the JDBC side is beyond
my ken.
regards, tom lane
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: Array of box not supported?
@ 2011-02-16 17:40 RW Shore <rws228@gmail.com>
parent: Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 0 replies; 3+ messages in thread
From: RW Shore @ 2011-02-16 17:40 UTC (permalink / raw)
To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: pgsql-jdbc
That did it, thanks much.
Ah, the joys of inconsistency (all other geometric types use or at least
accept comma - only box is different)
On Wed, Feb 16, 2011 at 12:17 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
> RW Shore <rws228@gmail.com> writes:
> > To insert into a box[ ], I need to convert the individual boxes into a
> > string. I get a "malformed array literal" error with any of the following
> > formats for a 1 dimensional array with two boxes:
>
> > {"1.0,1.0,0.0,0.0","10.0,10.0,0.0,0.0"}
> > {"((1.0,1.0),(0.0,0.0))","((10.0,10.0),(0.0,0.0))"}
> > {"(1.0,1.0),(0.0,0.0)","(10.0,10.0),(0.0,0.0)"}
>
> For historical reasons (well, I can see why they did it, but it's still
> weird), array of box uses semicolon not comma as the delimiter between
> array elements.
>
> regression=# select '{"1.0,1.0,0.0,0.0","10.0,10.0,0.0,0.0"}'::box[];
> ERROR: malformed array literal: "{"1.0,1.0,0.0,0.0","10.0,10.0,0.0,0.0"}"
> LINE 1: select '{"1.0,1.0,0.0,0.0","10.0,10.0,0.0,0.0"}'::box[];
> ^
> regression=# select '{"1.0,1.0,0.0,0.0";"10.0,10.0,0.0,0.0"}'::box[];
> box
> -----------------------------
> {(1,1),(0,0);(10,10),(0,0)}
> (1 row)
>
> The advantage is you don't need double quotes:
>
> regression=# select '{1.0,1.0,0.0,0.0;10.0,10.0,0.0,0.0}'::box[];
> box
> -----------------------------
> {(1,1),(0,0);(10,10),(0,0)}
> (1 row)
>
> Whether this requires any special pushups on the JDBC side is beyond
> my ken.
>
> regards, tom lane
>
^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2011-02-16 17:40 UTC | newest]
Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2011-02-16 16:25 Array of box not supported? RW Shore <rws228@gmail.com>
2011-02-16 17:17 ` Tom Lane <tgl@sss.pgh.pa.us>
2011-02-16 17:40 ` RW Shore <rws228@gmail.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