pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Dave Cramer <pg@fastcrypt.com>
To: Ken Johanson <pg-user@kensystem.com>
Cc: Michael Paesold <mpaesold@gmx.at>
Cc: pgsql-jdbc@postgresql.org
Subject: Re: Synthesize support for Statement.getGeneratedKeys()?
Date: Sun, 21 Jan 2007 21:29:52 -0500
Message-ID: <B480E0B4-9CE7-4FA3-B6F2-BC912AF2BC58@fastcrypt.com> (raw)
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>


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
>




view thread (50+ messages)  latest in thread

Message-ID: <B480E0B4-9CE7-4FA3-B6F2-BC912AF2BC58@fastcrypt.com>
Permalink:  ../B480E0B4-9CE7-4FA3-B6F2-BC912AF2BC58@fastcrypt.com/
Also on:    postgresql.org/message-id/B480E0B4-9CE7-4FA3-B6F2-BC912AF2BC58@fastcrypt.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-jdbc@postgresql.org
  Cc: pg@fastcrypt.com, pg-user@kensystem.com, mpaesold@gmx.at
  Subject: Re: Synthesize support for Statement.getGeneratedKeys()?
  In-Reply-To: <B480E0B4-9CE7-4FA3-B6F2-BC912AF2BC58@fastcrypt.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> <B480E0B4-9CE7-4FA3-B6F2-BC912AF2BC58@fastcrypt.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox