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

Re: in(...) clause and PreparedStatement

From: Dave Cramer <pg(at)fastcrypt(dot)com>
To: Sergey Pariev <egy(at)tnet(dot)dp(dot)ua>
Cc: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: in(...) clause and PreparedStatement
Date: 2005-06-13 13:07:11
Message-ID: 18349492-DC94-4DA4-B924-0FFC02F6A95B@fastcrypt.com (view raw or flat)
Thread:
Lists: pgsql-jdbc
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(at)postgresql(dot)org)
>
>


In response to

Responses

pgsql-jdbc by date

Next:From: Sergey ParievDate: 2005-06-13 13:08:55
Subject: in(...) clause and PreparedStatement
Previous:From: santosh dwivediDate: 2005-06-13 10:35:18
Subject: timestamp & graph time scale

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