Received: from localhost (maia-4.hub.org [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id 070B89FB227 for ; Sun, 21 Jan 2007 22:29:50 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-new, port 10024) with ESMTP id 62665-02 for ; Sun, 21 Jan 2007 22:29:46 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey-1.7.4 Received: from net2.micro-automation.com (net2.micro-automation.com [64.7.141.29]) by postgresql.org (Postfix) with SMTP id 28F579FB213 for ; Sun, 21 Jan 2007 22:29:46 -0400 (AST) Received: (qmail 24206 invoked from network); 22 Jan 2007 02:29:44 -0000 Received: from dcdsl.ebox.com (HELO ?192.168.1.14?) (davec@64.7.143.116) by net2.micro-automation.com with SMTP; 22 Jan 2007 02:29:44 -0000 In-Reply-To: <45B40AE1.8020003@kensystem.com> References: <4580E681.3080106@kensystem.com> <45810230.80803@gmx.at> <45B1AC19.3090300@kensystem.com> <45B1F839.3060402@gmx.at> <45B254D7.4080304@kensystem.com> <55027648-0777-4BE4-8581-933E86180539@fastcrypt.com> <45B3B9CB.3070308@kensystem.com> <3C6B3C20-CD94-4D35-B146-27DA78E6E462@fastcrypt.com> <45B40AE1.8020003@kensystem.com> Mime-Version: 1.0 (Apple Message framework v752.3) Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed Message-Id: Cc: Michael Paesold , pgsql-jdbc@postgresql.org Content-Transfer-Encoding: 7bit From: Dave Cramer Subject: Re: Synthesize support for Statement.getGeneratedKeys()? Date: Sun, 21 Jan 2007 21:29:52 -0500 To: Ken Johanson X-Mailer: Apple Mail (2.752.3) X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200701/137 X-Sequence-Number: 16502 On 21-Jan-07, at 7:52 PM, Ken Johanson wrote: > >>>>> 4) If 3b is required, then besides incrementing (by one) >>>>> sequences, any suggestions on how to correctly synthesize other >>>>> increment values? Other key types (OIDs, etc?) >>>> Are you suggesting here that you are planning on incrementing >>>> the sequences by 1 ? Why not just let the insert occur and get >>>> the currval of the sequence ? >>> >>> I'm thinking what you're thinking; get the current value; however >>> the increment I mention is just in case I cant get more than one >>> curval... I don't know, can I get 3 values from RETURN if I >>> insert three VALUEs in one query?? >> hmmm good question, one which I doubt the Sun people thought >> about. I wouldn't bother trying to return any more than the last one. >>> > > > Well, unless server generated keys can only be numeric (increment > by one, i.e predictable) (which is the only kind I've used), then I > think it's essential that we somehow can get each of the generated > keys. > > As for Sun/others, I do know that this feature works well in other > dbms's - every one I've used supports it, and with multiple rows > inserted. But I've only ever used numeric server generated keys so > I don't know if other types are supported on those DBs. OK, I should look at the spec before making statements above. This is possible in postgres, you can get whatever values were auto generated by the insert > > As an aside, how do PG jdbc users get the server generated keys? Or > does everyone use some kind of UUID system (which I think is > generally regarded as detrimental to indexes/memory under high load > and large DB sizes - compared to int/bigint)? Or do PG users using > some standard or server-specific (RETURNING) SQL clause? either create the key ahead of time select nextval('sequence') and insert it explicitly, or insert the row and then select currval ('sequence') Dave > > ken > > > > ---------------------------(end of > broadcast)--------------------------- > TIP 9: In versions below 8.0, the planner will ignore your desire to > choose an index scan if your joining column's datatypes do not > match >