Re: prepared statement using postgres array

From: Dave Cramer <pg(at)fastcrypt(dot)com>
To: Christian Kindler <christian(dot)kindler(at)gmx(dot)net>
Cc: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: prepared statement using postgres array
Date: 2007-12-01 12:35:38
Message-ID: 34910563-FEAB-4FF9-9381-E4D7DC3537F5@fastcrypt.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

Christian,

I'm doing this from memory so you may have to adjust.

you really only need to implement toString on the interface.
and the getBaseType.

the method has to output "{e0,e1,e2...}"

Where eN is the element of the array

Dave
On 30-Nov-07, at 12:43 PM, Christian Kindler wrote:

> Hi Dave
>
>> you have to implement the java.sql.Array
>
> hmmm ... i have tried to find a sample implementation of the
> interface, but no success.
>
> I am sure this is a ugly solution but I figures out a workaround:
>
> INSERT INTO Quote(fi_id, market_id, "date", "time",
> "open", high, low, "close", vol, oi,
> bid, bidvol, ask, askvol,
> last,
> sysstatus,
> buyers, buyersvol, sellers, sellersvol,
> additional)
> VALUES(?, ?, ?, ?,
> ?, ?, ?, ?, ?, ?,
> ?, ?, ?, ?,
> ?,
> ?,
> (select string_to_array(?, ',')::float[]),
> (select string_to_array(?, ',')::float[]),
> (select string_to_array(?, ',')::float[]),
> (select string_to_array(?, ',')::float[]),
> (select string_to_array(?, ',')::float[])
> );
>
> ... as is said not pretty but it works for the moment ...
>
> Thanks!
> Christian
>
> PS But it still will be cool if anybody could provide me a sample
> snipped implementing java.sql.Array
>
>
> --
> cu
> Chris
>
> Ist Ihr Browser Vista-kompatibel? Jetzt die neuesten
> Browser-Versionen downloaden: http://www.gmx.net/de/go/browser
>
> ---------------------------(end of
> broadcast)---------------------------
> TIP 3: Have you checked our extensive FAQ?
>
> http://www.postgresql.org/docs/faq

In response to

Browse pgsql-jdbc by date

  From Date Subject
Next Message Kris Jurka 2007-12-01 12:55:33 Re: prepared statement using postgres array
Previous Message Kris Jurka 2007-12-01 09:42:40 Re: getXXX throws SQLException while on insert row