Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id CA2D71337B47 for ; Tue, 5 Apr 2011 09:39:45 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.251]) (amavisd-maia, port 10024) with ESMTP id 58451-02-4 for ; Tue, 5 Apr 2011 12:39:27 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-gw0-f46.google.com (mail-gw0-f46.google.com [74.125.83.46]) by mail.postgresql.org (Postfix) with ESMTP id C20601337C03 for ; Tue, 5 Apr 2011 09:39:17 -0300 (ADT) Received: by gwaa18 with SMTP id a18so96764gwa.19 for ; Tue, 05 Apr 2011 05:39:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:message-id:date:from:user-agent:mime-version:to :subject:references:in-reply-to:content-type :content-transfer-encoding; bh=/xwIZ/3ol6ivni5wAO+K4J04q/GQCLZFvco+V+0Wbz8=; b=tLuw6fN8vVMK2KhJPYQ7W8SjNhtZ8/qDbwOUsJOoMWddTxCKDEXkMIJDBRxusf9eIv 99hsuz5j92aY8hIK7uxRxmYA+94033L8xyAti9R5fC+aS+KvmTZy+vIZqIXBD9JmQEYU g+z1ouhTxSWE7ZyW5RIAd7i3tv9KNs8qaABGA= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:content-type:content-transfer-encoding; b=faltvr6bLf+ssKnutnXctbROcVhaGvROil1hDIhgwDtbBGnO4enMuVODC3reaCEupG lXh3/ez7ZQDqReNm332+JEYE4GaAUy3HYpXLBxAn6u5tt+0izaydtvnYokwXEL3GPalZ gJDtYfEZCt+nHeaCuS61S9HSM8Q/5KAJUs0a4= Received: by 10.236.195.99 with SMTP id o63mr11495467yhn.238.1302007157330; Tue, 05 Apr 2011 05:39:17 -0700 (PDT) Received: from [114.74.147.157] ([114.74.147.157]) by mx.google.com with ESMTPS id m25sm2810590yhm.31.2011.04.05.05.39.14 (version=SSLv3 cipher=OTHER); Tue, 05 Apr 2011 05:39:16 -0700 (PDT) Message-ID: <4D9B0D6C.70707@gmail.com> Date: Tue, 05 Apr 2011 22:09:08 +0930 From: Daron Ryan User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.2.9) Gecko/20100915 Thunderbird/3.1.4 MIME-Version: 1.0 To: Heikki Linnakangas , pgsql-jdbc@postgresql.org Subject: Re: PreparedStatement for set membership (The IN operator) References: <4D9AC223.4000602@gmail.com> <4D9AD284.1090306@enterprisedb.com> In-Reply-To: <4D9AD284.1090306@enterprisedb.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.899 tagged_above=-10 required=5 tests=BAYES_00=-1.9, FREEMAIL_FROM=0.001 X-Spam-Level: X-Archive-Number: 201104/22 X-Sequence-Number: 21748 Thanks Heikki. I have tried using the setArray method but I am still running into an error. Exception in thread "main" org.postgresql.util.PSQLException: Unknown type _INTEGER. at org.postgresql.jdbc2.AbstractJdbc2Statement.setArray(AbstractJdbc2Statement.java:2800) at dictionary.test.Main.main(Main.java:85) This is the Array implementation I have created. http://pastebin.com/tkzPRL4A For baseTypeName I have also tried "int" and received the same error referring to type _int instead. This is the code I used to test the implementation calling code http://pastebin.com/T1mvADaF Any idea what I need to do? On 5/04/2011 5:57 PM, Heikki Linnakangas wrote: > 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. >