Received: from localhost (maia-2.hub.org [200.46.204.187]) by postgresql.org (Postfix) with ESMTP id 1EFB39FB4BF for ; Sat, 20 Jan 2007 01:59:40 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.187]) (amavisd-new, port 10024) with ESMTP id 47653-07 for ; Sat, 20 Jan 2007 01:59:30 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey-1.7.4 Received: from www01.kensystem.com (www01.kensystem.com [72.19.170.120]) by postgresql.org (Postfix) with ESMTP id 333299FB324 for ; Sat, 20 Jan 2007 01:59:36 -0400 (AST) Received: from 192.168.0.3 by www01.kensystem.com (SMTPD); id s20070120055930.6280; Sat, 20 Jan 2007 05:59:30 Message-ID: <45B1AFC2.5060900@kensystem.com> Date: Fri, 19 Jan 2007 22:59:30 -0700 From: Ken Johanson User-Agent: Thunderbird 1.5.0.9 (Windows/20061207) MIME-Version: 1.0 To: pgsql-jdbc@postgresql.org CC: Michael Paesold Subject: Re: Synthesize support for Statement.getGeneratedKeys()? References: <4580E681.3080106@kensystem.com> <45810230.80803@gmx.at> <45B1AC19.3090300@kensystem.com> In-Reply-To: <45B1AC19.3090300@kensystem.com> Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200701/128 X-Sequence-Number: 16493 > > If someone has pointers to where the augmentaion code should be placed > (org.tgresql.jdbc3.Jdbc3ResultSetMetadata I presume), and also the > protocol (separate query to the server?, or append RETURNING clause to > the DML?). > > Also I cant remember - is it true that when inserting multuple VALUES, > that only the first (or last) SEQUENCE can be retrived, or can I > populate a resultset using the RETURNING data from by the server? > Answering my own question here... sort of :) http://www.postgresql.org/docs/current/static/sql-insert.html In the case of inserting multiple values (say 3 rows), is there a clever way to get the last 3 sequences via native SQL? Or would the JDBC code need to synthesize them?: (very simplified) ...exec rs.next();//single key returned Object id = rs.getObject(); Object[] keys = new Object[insertedRowCount]; for (; keys.length; i++) keys[i] = increment(id); myPGResultSet.populate(userDeclaredKeyNameOrIdx, keys);//hypothetical - i didn't look at the API yet, sorry