Received: from maia.hub.org (maia-5.hub.org [200.46.204.29]) by mail.postgresql.org (Postfix) with ESMTP id A4E211337B9C for ; Tue, 5 Apr 2011 05:34:06 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.29]) (amavisd-maia, port 10024) with ESMTP id 01157-02-5 for ; Tue, 5 Apr 2011 08:33:57 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from exprod7og108.obsmtp.com (exprod7og108.obsmtp.com [64.18.2.169]) by mail.postgresql.org (Postfix) with ESMTP id C6A451337C2F for ; Tue, 5 Apr 2011 05:33:50 -0300 (ADT) Received: from mail-ew0-f52.google.com ([209.85.215.52]) (using TLSv1) by exprod7ob108.postini.com ([64.18.6.12]) with SMTP ID DSNKTZrT7gze1+zM2rJVJCIJOFKFrvawhvOu@postini.com; Tue, 05 Apr 2011 01:33:51 PDT Received: by mail-ew0-f52.google.com with SMTP id 28so48165ewy.11 for ; Tue, 05 Apr 2011 01:33:49 -0700 (PDT) Received: by 10.14.4.90 with SMTP id 66mr3664338eei.137.1301992071774; Tue, 05 Apr 2011 01:27:51 -0700 (PDT) Received: from [192.168.1.183] (dsl-hkibrasgw2-ff7ac300-240.dhcp.inet.fi [88.195.122.240]) by mx.google.com with ESMTPS id q53sm3838634eeh.4.2011.04.05.01.27.49 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 05 Apr 2011 01:27:50 -0700 (PDT) Message-ID: <4D9AD284.1090306@enterprisedb.com> Date: Tue, 05 Apr 2011 11:27:48 +0300 From: Heikki Linnakangas User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; fi-FI; rv:1.9.1.16) Gecko/20110307 Icedove/3.0.11 MIME-Version: 1.0 To: Daron Ryan CC: pgsql-jdbc@postgresql.org Subject: Re: PreparedStatement for set membership (The IN operator) References: <4D9AC223.4000602@gmail.com> In-Reply-To: <4D9AC223.4000602@gmail.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.9 tagged_above=-10 required=5 tests=BAYES_00=-1.9 X-Spam-Level: X-Archive-Number: 201104/21 X-Sequence-Number: 21747 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