From: Heikki Linnakangas <heikki.linnakangas@enterprisedb.com>
To: Daron Ryan <daron.ryan@gmail.com>
Cc: pgsql-jdbc@postgresql.org
Subject: Re: PreparedStatement for set membership (The IN operator)
Date: Tue, 05 Apr 2011 11:27:48 +0300
Message-ID: <4D9AD284.1090306@enterprisedb.com> (raw)
In-Reply-To: <4D9AC223.4000602@gmail.com>
References: <4D9AC223.4000602@gmail.com>
On 05.04.2011 10:17, Daron Ryan wrote:
> Hello,
>
> I need to use a SELECT statement with varying data for set membership. IE.
>
> SELECT link_id
> FROM links
> WHERE heading_id IN (?, ?, ?)
>
> It won't always be the same number of members in the set. I am using an
> ordinary statement with an executeQuery call but would prefer to use a
> PreparedStatement. Is this possible? If so how do I set the values in
> the set?
You can do "WHERE heading_id = ANY (?)", and pass an array of the ids
for the parameter.
--
Heikki Linnakangas
EnterpriseDB http://www.enterprisedb.com
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: heikki.linnakangas@enterprisedb.com, daron.ryan@gmail.com
Subject: Re: PreparedStatement for set membership (The IN operator)
In-Reply-To: <4D9AD284.1090306@enterprisedb.com>
References: <4D9AC223.4000602@gmail.com> <4D9AD284.1090306@enterprisedb.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