pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Dave Cramer <pg@fastcrypt.com>
To: Sergey Pariev <egy@tnet.dp.ua>
Cc: pgsql-jdbc@postgresql.org
Subject: Re: in(...) clause and PreparedStatement
Date: Mon, 13 Jun 2005 09:07:11 -0400
Message-ID: <18349492-DC94-4DA4-B924-0FFC02F6A95B@fastcrypt.com> (raw)
In-Reply-To: <42AD8567.10004@tnet.dp.ua>
References: <42AD8567.10004@tnet.dp.ua>

Yes, because it thinks "1,2,3" is a string

you would have to do

IN(?,?,?)

then

setObject(1, 1);
setObject(2, 2);
setObject(3, 3);

Dave

On 13-Jun-05, at 9:08 AM, Sergey Pariev wrote:

> Hi all.
>    It may be stupid question, but is there way to use  
> PreparedStatement with queries like
> SELECT * FROM mytable WHERE t_id IN (1,2,3) ?
>    I've googled but haven't found nothing explicitly said on this  
> topic.
>    I've tried the following
>    PreparedStatement st = conn.prepareStatement("SELECT * FROM  
> mytable WHERE t_id IN ( ? )");
>    st.setObject(1,"1,2,3");
>
>    and get error complaining on type mismatch.
>
>    Thanks in advance, Sergey.
>
> ---------------------------(end of  
> broadcast)---------------------------
> TIP 2: you can get off all lists at once with the unregister command
>    (send "unregister YourEmailAddressHere" to  
> majordomo@postgresql.org)
>
>




view thread (6+ messages)  latest in thread

Message-ID: <18349492-DC94-4DA4-B924-0FFC02F6A95B@fastcrypt.com>
Permalink:  ../18349492-DC94-4DA4-B924-0FFC02F6A95B@fastcrypt.com/
Also on:    postgresql.org/message-id/18349492-DC94-4DA4-B924-0FFC02F6A95B@fastcrypt.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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-jdbc@postgresql.org
  Cc: pg@fastcrypt.com, egy@tnet.dp.ua
  Subject: Re: in(...) clause and PreparedStatement
  In-Reply-To: <18349492-DC94-4DA4-B924-0FFC02F6A95B@fastcrypt.com>
  References: <42AD8567.10004@tnet.dp.ua> <18349492-DC94-4DA4-B924-0FFC02F6A95B@fastcrypt.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