Skip site navigation (1) Skip section navigation (2)

Re: Prepare Statement

From: Oliver Jowett <oliver(at)opencloud(dot)com>
To: Jie Liang <jie(at)stbernard(dot)com>
Cc: Kris Jurka <books(at)ejurka(dot)com>, pgsql-jdbc(at)postgresql(dot)org
Subject: Re: Prepare Statement
Date: 2004-06-18 23:07:03
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-jdbcpgsql-sql
Jie Liang wrote:
> So, I think that PreparedStatement should have a way at least case a
> String to an Array or a way to create a Array, because of
> conn.prepareStatement("SELECT myfunction('{1,2,3}')") is NOT very
> useful.

One way that might work in the current driver is to use PGobject, which 
lets you specify the underlying typename to use:

   stmt = conn.preparedStatement("SELECT myfunction(?)");
   org.postgresql.util.PGobject obj = new PGobject();
   stmt.setObject(1, obj);

Untested, but in theory this should work even with 
setUseServerPrepare(true) in effect.

Also, if you search the archives, quite some time ago (a year?) I posted 
a patch that implemented setArray() better, so that you could pass your 
own Array implementation to it and have things work correctly. It's out 
of date, but might give you a starting point.


In response to

pgsql-sql by date

Next:From: Riccardo G. FacchiniDate: 2004-06-19 06:03:30
Subject: Re: plpgsql - Insert from a record variable?
Previous:From: Kris JurkaDate: 2004-06-18 21:47:53
Subject: Re: Prepare Statement

pgsql-jdbc by date

Next:From: Oliver JowettDate: 2004-06-18 23:10:11
Subject: Re: proposal for CallableStatements to handle multiple out
Previous:From: Tom LaneDate: 2004-06-18 22:47:10
Subject: Re: Nested transactions

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group