pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Oliver Jowett <oliver@opencloud.com>
To: Jie Liang <jie@stbernard.com>
Cc: Kris Jurka <books@ejurka.com>
Cc: pgsql-jdbc@postgresql.org
Subject: Re: Prepare Statement
Date: Sat, 19 Jun 2004 11:07:03 +1200
Message-ID: <40D37597.9030705@opencloud.com> (raw)
In-Reply-To: <E7E213858379814A9AE48CA6754F5ECB03451966@mail01.stbernard.com>
References: <E7E213858379814A9AE48CA6754F5ECB03451966@mail01.stbernard.com>

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();
   obj.setValue("'{1,2,3}'");
   obj.setType("int[]");
   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.

-O



view thread (19+ messages)  latest in thread

Message-ID: <40D37597.9030705@opencloud.com>
Permalink:  ../40D37597.9030705@opencloud.com/
Also on:    postgresql.org/message-id/40D37597.9030705@opencloud.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: oliver@opencloud.com, jie@stbernard.com, books@ejurka.com, pgsql-jdbc@postgresql.org
  Subject: Re: Prepare Statement
  In-Reply-To: <40D37597.9030705@opencloud.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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