Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id 009191337B7A for ; Thu, 2 Dec 2010 02:44:46 -0400 (AST) 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 41663-08; Thu, 2 Dec 2010 06:44:38 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from www.postnewspapers.com.au (www.postnewspapers.com.au [173.230.139.50]) by mail.postgresql.org (Postfix) with ESMTP id A0D811337B55; Thu, 2 Dec 2010 02:44:38 -0400 (AST) Received: from localhost (localhost [127.0.0.1]) by www.postnewspapers.com.au (Postfix) with ESMTP id 5658914A7; Thu, 2 Dec 2010 01:44:37 -0500 (EST) X-Virus-Scanned: amavisd-new at postnewspapers.com.au.com Received: from www.postnewspapers.com.au ([127.0.0.1]) by localhost (www.postnewspapers.com.au [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 4qfjwZUG8Q9L; Thu, 2 Dec 2010 01:44:36 -0500 (EST) Received: from mail.postnewspapers.com.au (ppp171-128.static.internode.on.net [150.101.171.128]) by www.postnewspapers.com.au (Postfix) with ESMTP id 7302219; Thu, 2 Dec 2010 01:44:36 -0500 (EST) Received: from [10.0.0.53] (wallace.localnet [10.0.0.53]) by mail.postnewspapers.com.au (Postfix) with ESMTP id 6925C200B; Thu, 2 Dec 2010 14:44:35 +0800 (WST) Message-ID: <4CF74051.7010102@postnewspapers.com.au> Date: Thu, 02 Dec 2010 14:44:33 +0800 From: Craig Ringer User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.9) Gecko/20100423 Thunderbird/3.0.4 MIME-Version: 1.0 To: Zhipan Wang CC: pgsql-jdbc@postgresql.org, pgsql-general@postgresql.org Subject: Re: [JDBC] ResultSet problem in JDBC References: <3682665.914331291266886473.JavaMail.root@mail-01.cse.ucsc.edu> In-Reply-To: <3682665.914331291266886473.JavaMail.root@mail-01.cse.ucsc.edu> X-Enigmail-Version: 1.0.1 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.91 tagged_above=-5 required=5 tests=BAYES_00=-1.9, T_RP_MATCHES_RCVD=-0.01 X-Spam-Level: X-Archive-Number: 201012/55 X-Sequence-Number: 170346 On 02/12/10 13:14, Zhipan Wang wrote: > Statement st = c.createStatement(); > ResultSet r = st.executeQuery("select unnest(col0) from relation2_col1 > where keyValue<500"); > PreparedStatement sql = c.prepareStatement( "SELECT col1 FROM relation2 > WHERE col0 IN ?"); > sql.setObject(1, r); > ResultSet result = sql.executeQuery(); You appear to be trying to implement a subquery client-side. Why not just use: PreparedStatement sql = c.prepareStatement( "SELECT col1 FROM relation2 WHERE col0 IN "+ "(SELECT unnest(col0) from relation2_col1 where keyValue<500" ); ? It's hard to know whether the above is correct because you've failed to provide your schema, but something along those lines seems to fit your intent from the code above. > I am using Eclipse, and there is no warning for this code. No, Eclipse can't know the details of how every JDBC driver works. > Can't a result set be used in another query? How do I correct it? Either build an array with the contents of the resultset and pass that, or avoid the weirdness by using a subquery directly. -- System & Network Administrator POST Newspapers