Received: from localhost (maia-5.hub.org [200.46.204.182]) by postgresql.org (Postfix) with ESMTP id 62C159FA2CA for ; Thu, 14 Dec 2006 03:50:13 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.182]) (amavisd-new, port 10024) with ESMTP id 53664-03 for ; Thu, 14 Dec 2006 03:50:05 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey-1.7.4 Received: from mail.gmx.net (mail.gmx.net [213.165.64.20]) by postgresql.org (Postfix) with SMTP id 7B4769FA162 for ; Thu, 14 Dec 2006 03:50:07 -0400 (AST) Received: (qmail invoked by alias); 14 Dec 2006 07:50:06 -0000 Received: from office01.emerion.com (EHLO [127.0.0.1]) [83.64.50.26] by mail.gmx.net (mp032) with SMTP; 14 Dec 2006 08:50:06 +0100 X-Authenticated: #1946847 Message-ID: <45810230.80803@gmx.at> Date: Thu, 14 Dec 2006 08:50:08 +0100 From: Michael Paesold User-Agent: Thunderbird 1.5.0.8 (Windows/20061025) MIME-Version: 1.0 To: Ken Johanson CC: pgsql-jdbc@postgresql.org Subject: Re: Synthesize support for Statement.getGeneratedKeys()? References: <4580E681.3080106@kensystem.com> In-Reply-To: <4580E681.3080106@kensystem.com> Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 7bit X-Y-GMX-Trusted: 0 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200612/72 X-Sequence-Number: 16304 Ken Johanson wrote: > Hello, > > I've just come to realize that Statement.getGeneratedKeys() is not > supported in the current PG and/or JDBC driver. Does someone know if > this is a limitation of PG, or its protocol, or just not yet implemented > in the JDBC driver? I'm just wondering where, if at all (if I have > enough brain cells that is :), I could try to offer a patch or ideas.. It would be possible to implement that using the RETURNING clause supported in recent versions of the server. See here: http://archives.postgresql.org/pgsql-jdbc/2006-10/msg00035.php http://archives.postgresql.org/pgsql-jdbc/2006-10/msg00037.php Unfortunately, all my available spare time went into implementing support for standards_conforming_strings in the 8.2 release cycle. > Then question 2; I did see a discussion where it was suggested that we > could get roughly the same effect by issuing a > SELECT currval(''); after the DML... > http://archives.postgresql.org/pgsql-jdbc/2005-10/msg00035.php > Would it then be feasible internal to the JDBC driver to (create an > option that would enable) always implicitly append that query to the > (String)sql arg of Statment.executeUpdate(String sql, String[] > columnNames)? I mean, just internally attempt to create the same > behavior as what this method should be doing? As was discussed before, a solution just for sequences is not general enough, therefore the RETURNING thing. > Question 3 is, it seems like option two would only return the last > created key, not set of keys, in the case where multiple rows were > inserted.. is this accurate? Seems correct. And that's one of the objections to the idea. > Unfortunately if I cant find a way to make my target-app work with PG > (without adding PG-specific modifications for getting keys), I'm > probably not going to be able to make the switch to PG unfortunately - > the code I'm working with makes really, really extensive use of > retrieved keys.. Could you comment on my mail above (the second one) -- what API-methods does your software use, actually? Best Regards Michael Paesold