X-Original-To: pgsql-jdbc-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 34B7C56850 for ; Tue, 15 Mar 2005 05:56:54 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 12655-05 for ; Tue, 15 Mar 2005 05:56:49 +0000 (GMT) Received: from yass.opencloud.co.nz (yass.opencloud.co.nz [203.79.85.162]) by svr1.postgresql.org (Postfix) with ESMTP id 8E2F65681B for ; Tue, 15 Mar 2005 05:56:45 +0000 (GMT) Received: from 203-79-104-60.cable.paradise.net.nz ([203.79.104.60] helo=[192.168.0.20]) by yass.opencloud.co.nz with asmtp (Exim 3.35 #1 (Debian)) id 1DB52k-0003qY-00; Tue, 15 Mar 2005 18:56:38 +1300 Message-ID: <42367913.8070704@opencloud.com> Date: Tue, 15 Mar 2005 18:56:35 +1300 From: Oliver Jowett User-Agent: Mozilla Thunderbird 1.0 (X11/20041228) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Joseph Shraibman Cc: pgsql-jdbc@postgresql.org Subject: Re: executeUpdate("SELECT INTO") References: <42366B61.9030203@selectacast.net> In-Reply-To: <42366B61.9030203@selectacast.net> X-Enigmail-Version: 0.89.5.0 X-Enigmail-Supports: pgp-inline, pgp-mime Content-Type: multipart/mixed; boundary="------------080702070008070204070708" X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.005 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200503/149 X-Sequence-Number: 12541 This is a multi-part message in MIME format. --------------080702070008070204070708 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Joseph Shraibman wrote: > How come executeUpdate() always returns 1 when the sql is SELECT ... > INTO TEMP tablename ? I'm using pg 7.4.7 I just tried the CVS driver against 7.4.6 and 8.0.0 servers, and both return 0 in this case, regardless of the actual number of rows inserted. I don't have a 7.4.7 build to hand, but I'd expect it to behave the same as 7.4.6. Returning 0 is ok according to the JDBC spec, which says that executeUpdate returns "either the row count for INSERT, UPDATE or DELETE statements, or 0 for SQL statements that return nothing". We can't return a row count here anyway, as the server doesn't tell us the number of rows inserted by a SELECT INTO. If you're seeing a return value of 1, that does seem wrong. Can you provide some test code showing the problem? We'd also need to know exactly which driver build you are using. The test code I used is attached. -O --------------080702070008070204070708 Content-Type: text/plain; name="TestSelectInto.java" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="TestSelectInto.java" import java.sql.*; // Run with one argument: a JDBC url to connect to. public class TestSelectInto { public static void main(String[] args) throws Exception { Class.forName("org.postgresql.Driver"); Connection c = DriverManager.getConnection(args[0]); Statement s = c.createStatement(); s.executeUpdate("CREATE TEMP TABLE t1 (i integer); INSERT INTO t1(i) VALUES (1); INSERT INTO t1(i) VALUES (2)"); int count = s.executeUpdate("SELECT i INTO TEMP TABLE t2 FROM t1"); System.out.println("Update count: " + count); s.close(); c.close(); } } --------------080702070008070204070708--