Received: from localhost (unknown [200.46.208.211]) by mail.postgresql.org (Postfix) with ESMTP id 5A9D2634312 for ; Mon, 9 Mar 2009 16:22:49 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.208.211]) (amavisd-maia, port 10024) with ESMTP id 81452-04-6 for ; Mon, 9 Mar 2009 16:22:42 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from smtp.nmset.info (cop60-2-88-163-134-117.fbx.proxad.net [88.163.134.117]) by mail.postgresql.org (Postfix) with ESMTP id 3B9D5634242 for ; Mon, 9 Mar 2009 16:22:27 -0300 (ADT) Received: by smtp.nmset.info (Postfix, from userid 65534) id 8ED3198395; Mon, 9 Mar 2009 20:22:23 +0100 (CET) Received: from vos.nmset.info (cop60-2-88-163-134-117.fbx.proxad.net [88.163.134.117]) by smtp.nmset.info (Postfix) with ESMTP id 7E8449838E for ; Mon, 9 Mar 2009 20:22:16 +0100 (CET) From: "Saleem EDAH-TALLY" To: pgsql-jdbc@postgresql.org Subject: getGeneratedKeys Date: Mon, 9 Mar 2009 20:20:58 +0100 User-Agent: KMail/1.11.1 (Linux/2.6.27.7; KDE/4.2.1; x86_64; ; ) MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="Boundary-00=_awWtJVYhqkmC+VK" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200903092020.58921.nmset@netcourrier.com> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=1.218 tagged_above=0 required=5 tests=HTML_MESSAGE=0.001, RCVD_IN_SORBS_WEB=1.117, RDNS_DYNAMIC=0.1 X-Spam-Level: * X-Archive-Number: 200903/36 X-Sequence-Number: 19366 --Boundary-00=_awWtJVYhqkmC+VK Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Hello, This is just a request in the hope it may help not all but 95% of devs. The other 5% would know by notice that they have to write their own solution; for now, 100% of devs have to write their own. I have followed http://archives.postgresql.org//pgsql-jdbc/2004-09/msg00191.php and http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&c2coff=1&safe=off&threadm=Pine.LNX.4.33.0312301523060.5331-100000@leary.csoft.net&rnum=3&prev=/groups?q=generated+keys&hl=en&lr=&ie=UTF-8&group=comp.databases.postgresql.interfaces.jdbc&c2coff=1&safe=off&selm=Pine.LNX.4.33.0312301523060.5331-100000%40leary.csoft.net&rnum=3 and I understand quite well that currval is useless with multiple inserted rows, and the one inserted row situation with two colums having the same sequence as default values cannot rely on currval. I consider these situations to be in those 5% or less where the devs know what they are doing. Sequences appended to columns as defaults can easily be retrieved "SELECT column_default FROM information_schema.columns WHERE table_name = '" + tblName + "' AND column_default LIKE 'nextval(''%_%_seq''::regclass)'" The driver may parse the results to get the sequence(s) name(s) and hence querying again to retrieve the currval(s), returning a resultset with most often one column and more if there are more than one column with a sequence as default value. If the same same sequence is found more than one time as default value, then the driver may generate an error as 'not implemented'. Of course multiple inserted rows cannot be managed at all. Concerning having more than one same sequence as default values in a table is quite an odd situation. Serious devs won't do that. A table could yet have more than column with a sequence as default, and the returned generated keys could all be forwarded by the driver if the sequences are all different. So I think the driver may provide getGeneratedKeys in a realistic approach, and generating errors for these very rare odd situations. Thank you for considering. --Boundary-00=_awWtJVYhqkmC+VK Content-Type: text/html; charset="utf-8" Content-Transfer-Encoding: 7bit Hello,


This is just a request in the hope it may help not all but 95% of devs. The other 5% would know by notice that they have to write their own solution; for now, 100% of devs have to write their own.


I have followed
http://archives.postgresql.org//pgsql-jdbc/2004-09/msg00191.php
and
http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&c2coff=1&safe=off&threadm=Pine.LNX.4.33.0312301523060.5331-100000@leary.csoft.net&rnum=3&prev=/groups?q=generated+keys&hl=en&lr=&ie=UTF-8&group=comp.databases.postgresql.interfaces.jdbc&c2coff=1&safe=off&selm=Pine.LNX.4.33.0312301523060.5331-100000%40leary.csoft.net&rnum=3
and I understand quite well that currval is useless with multiple inserted rows, and the one inserted row situation with two colums having the same sequence as default values cannot rely on currval. I consider these situations to be in those 5% or less where the devs know what they are doing.


Sequences appended to columns as defaults can easily be retrieved


"SELECT column_default FROM information_schema.columns WHERE table_name = '" + tblName + "' AND column_default LIKE 'nextval(''%_%_seq''::regclass)'"


The driver may parse the results to get the sequence(s) name(s) and hence querying again to retrieve the currval(s), returning a resultset with most often one column and more if there are more than one column with a sequence as default value. If the same same sequence is found more than one time as default value, then the driver may generate an error as 'not implemented'.


Of course multiple inserted rows cannot be managed at all.


Concerning having more than one same sequence as default values in a table is quite an odd situation. Serious devs won't do that.


A table could yet have more than column with a sequence as default, and the returned generated keys could all be forwarded by the driver if the sequences are all different.


So I think the driver may provide getGeneratedKeys in a realistic approach, and generating errors for these very rare odd situations.


Thank you for considering.


--Boundary-00=_awWtJVYhqkmC+VK--