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 AAEEB8BA169 for ; Sat, 19 Feb 2005 17:38:28 +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 11677-05 for ; Sat, 19 Feb 2005 17:38:19 +0000 (GMT) Received: from mail-in-06.arcor-online.net (mail-in-06.arcor-online.net [151.189.21.46]) by svr1.postgresql.org (Postfix) with ESMTP id D85D28BA10D for ; Sat, 19 Feb 2005 17:38:19 +0000 (GMT) Received: from gwinet.sven.home-net (dsl-082-083-001-031.arcor-ip.net [82.83.1.31]) by mail-in-06.arcor-online.net (Postfix) with ESMTP id 7D5A510E001; Sat, 19 Feb 2005 18:38:16 +0100 (CET) Received: from [10.1.1.20] (unknown [10.1.1.20]) by gwinet.sven.home-net (Postfix) with ESMTP id 25DE98CEA59; Sat, 19 Feb 2005 18:38:16 +0100 (CET) Message-ID: <42177A2A.5000304@upb.de> Date: Sat, 19 Feb 2005 18:40:58 +0100 From: =?ISO-8859-15?Q?Sven_K=F6hler?= User-Agent: Mozilla Thunderbird 1.0 (Windows/20041206) X-Accept-Language: de-DE, de, en-us, en MIME-Version: 1.0 Newsgroups: gmane.comp.db.postgresql.jdbc To: pg@fastcrypt.com Cc: "pgsql-jdbc@postgresql.org" Subject: Re: getGeneratedKeys method References: <20040526115632.87009.qmail@web51008.mail.yahoo.com> <1085573511.1654.20.camel@localhost.localdomain> In-Reply-To: <1085573511.1654.20.camel@localhost.localdomain> Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= X-Spam-Level: X-Archive-Number: 200502/135 X-Sequence-Number: 12315 > Yes, this is correct, there is no functionality in postgres to get the > generated keys. That's sad. > This is because the keys are generated using a sequence which can be any > of the columns in the row, there is no apriori knowledge of the column > that is being generated. First, we have to define what a "generated key" is! If you define it as a value generated by a sequence, than this is hard to find out. Simply take the following definition: A column in the primary key is a "generated key", iff a value for the columns hasn't been given in the INSERT and if the column has a default value. With this definition, is should be easy for the server to find the generated keys. > 2) get the key after the insert leaving the key value out of the insert, > or inserting a null there. select currval('sequence_name'); but you have to know the sequence name for that. That's really bad!