X-Original-To: pgsql-jdbc-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by postgresql.org (Postfix) with ESMTP id 3CF3F9DCADB for ; Tue, 6 Dec 2005 08:55:26 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 05187-04 for ; Tue, 6 Dec 2005 08:55:29 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey- Received: from net2.micro-automation.com (net2.micro-automation.com [64.7.141.29]) by postgresql.org (Postfix) with SMTP id D3B369DCAC4 for ; Tue, 6 Dec 2005 08:55:23 -0400 (AST) Received: (qmail 25209 invoked from network); 6 Dec 2005 12:55:24 -0000 Received: from dcdsl.ebox.com (HELO ?192.168.1.2?) (davec@64.7.143.116) by net2.micro-automation.com with SMTP; 6 Dec 2005 12:55:24 -0000 In-Reply-To: References: Mime-Version: 1.0 (Apple Message framework v746.2) Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed Message-Id: <0E851503-1490-4B97-93E5-BA7EC64D96E3@fastcrypt.com> Cc: pgsql-jdbc@postgresql.org Content-Transfer-Encoding: 7bit From: Dave Cramer Subject: Re: bug with 8.X level 4 driver? Date: Tue, 6 Dec 2005 07:55:22 -0500 To: Damon Anderson X-Mailer: Apple Mail (2.746.2) X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0.064 required=5 tests=[AWL=0.064] X-Spam-Score: 0.064 X-Spam-Level: X-Archive-Number: 200512/24 X-Sequence-Number: 14355 Damon, Try using batches instead. The new driver can no longer do multiple statements that way. Dave On 6-Dec-05, at 1:40 AM, Damon Anderson wrote: > Hello, > > I currently have a problem with the following statement: > > ppS = dd.createPPStatement(); > ppS.setQueryString( > "INSERT INTO sandwich_side (name) VALUES > ('pickles');" + > "INSERT INTO sandwich ( name, sideid) VALUES > ('club', currval('sandwich_side_id_seq'));" + > "SELECT currval('sandwich_side_id_seq')"); > Resultset rs = ppS.getPreparedStatement().executeQuery(); > try { > while( rs.next()) {} > } catch { SQLException ex1) { > ex1.printStackTrace(); > } > > (This use to work, but updated to 8.X driver (for a unicode issue)) > SQLMessage: No results were returned by the query. > Statement: Pooled statement wrapping physical statement INSERT INTO > sandwich_side (name) VALUES ('pickles');INSERT INTO sandwich > ( name, sideid) VALUES('club', currval > ('sandwich_side_id_seq'));SELECT currval('sandwich_side_id_seq') > org.postgresql.util.PSQLException: No results were returned by the > query. > at org.postgresql.jdbc2.AbstractJdbc2Statement.executeQuery > (AbstractJdbc2Statement.java:241) > > ------------------ > > So did some searching on the forums, lists, etc.. Changed it to this: > try > { > ppS = dd.createPPStatement(); > ppS.setQueryString( > "INSERT INTO sandwich_side (name) VALUES > ('pickles');" + > "INSERT INTO sandwich ( name, sideid) VALUES > ('club', currval('sandwich_side_id_seq'));" + > "SELECT currval('sandwich_side_id_seq')"); > ppS.initStatement(); //Prepares the statement. > ppS.getPreparedStatement().execute(); > if( ppS.getPreparedStatement().getMoreResults()) > rs = ppS.getPreparedStatement().getResultSet(); > } > catch (SQLException ex1) > { > ex1.printStackTrace(); > } > > //ResultSet rs = ppS.getGeneratedKeys(); > try > { > while (rs.next()) <----- > { > System.err.println("getInt: " + rs.getInt(1)); > } > } > catch (SQLException ex) { ex.printStackTrace(); } > > So at the moment I can't get the serial id that was created for > this new insert. The old way with just executeQuery worked great > (must be 7.X driver). I tried several version of the 8.X driver, > but all had the same results. > > Anyone have the same results? Doing something wrong? > > Thanks much, > > Damon > P.S. This is with version 8.0 postgresql server. > > ---------------------------(end of > broadcast)--------------------------- > TIP 5: don't forget to increase your free space map settings >