Re: Array of box not supported?

From: RW Shore <rws228(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: Array of box not supported?
Date: 2011-02-16 17:40:12
Message-ID: AANLkTiniFmC1QYvxFu00=hp4+1VG4P5uo8FbU+SwPfky@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(at)sss(dot)pgh(dot)pa(dot)us> wrote:

> RW Shore <rws228(at)gmail(dot)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
>

In response to

Browse pgsql-jdbc by date

  From Date Subject
Next Message Oliver Jowett 2011-02-17 00:14:46 Re: Fwd: [JDBC] Weird issues when reading UDT from stored function
Previous Message Tom Lane 2011-02-16 17:17:59 Re: Array of box not supported?