Re: Synthesize support for Statement.getGeneratedKeys()? - Mailing list pgsql-jdbc

From Ken Johanson
Subject Re: Synthesize support for Statement.getGeneratedKeys()?
Date
Msg-id 45B44726.1070301@kensystem.com
Whole thread Raw
In response to Re: Synthesize support for Statement.getGeneratedKeys()?  (Dave Cramer <pg@fastcrypt.com>)
Responses Re: Synthesize support for Statement.getGeneratedKeys()?
Re: Synthesize support for Statement.getGeneratedKeys()?
List pgsql-jdbc
>> 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')
>


That makes sense; the sequence is retrieved and it internally increments
- regardless of whether the key was actually inserted or not. I'm
personally not used to this though, it allows for actual keys in the
database to possibly have gaps (if the key want actually used / rollback
etc). Thats trivial / innocuous I guess, but I'm just used to having
sequential keys tables. Would this require two trips to the server, or
can we handle in one excecuteUpdate?

My real question is, what about the case where multiple VALUES are
inserted; if I have 3 values should I call the sequence 3 times? What is
the most efficient was to do that? (Can I do it in a single query?)

Thank you,
ken



pgsql-jdbc by date:

Previous
From: Dave Cramer
Date:
Subject: Re: Synthesize support for Statement.getGeneratedKeys()?
Next
From: "Michael Schmidt"
Date:
Subject: Re: pg_dump in PostgreSQL version 8.2 not working in Java app