pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
How to get generated primary key?
3+ messages / 3 participants
[nested] [flat]

* How to get generated primary key?
@ 2005-02-19 17:15 Sven Köhler <skoehler@upb.de>
  2005-02-19 20:21 ` Re: How to get generated primary key? Kris Jurka <books@ejurka.com>
  0 siblings, 1 reply; 3+ messages in thread

From: Sven Köhler @ 2005-02-19 17:15 UTC (permalink / raw)
  To: pgsql-jdbc

Hi,

i know about the nextval and currval functions, but i don't like them, 
since they don't apply to tables. To get the generated key, you have to 
know the name of the sequence, not just the name of the table.

Does the JDBC-Driver implement the getGeneratedKeys() method?
If not, does PostgreSQL provide any way to get the just generated key, 
without knowing the sequencename?


Thx
   Sven




^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: How to get generated primary key?
  2005-02-19 17:15 How to get generated primary key? Sven Köhler <skoehler@upb.de>
@ 2005-02-19 20:21 ` Kris Jurka <books@ejurka.com>
  2005-02-20 16:48   ` Re: How to get generated primary key? Dave Cramer <pg@fastcrypt.com>
  0 siblings, 1 reply; 3+ messages in thread

From: Kris Jurka @ 2005-02-19 20:21 UTC (permalink / raw)
  To: Sven Köhler <skoehler@upb.de>; +Cc: pgsql-jdbc



On Sat, 19 Feb 2005, [ISO-8859-15] Sven Köhler wrote:

> i know about the nextval and currval functions, but i don't like them, 
> since they don't apply to tables. To get the generated key, you have to 
> know the name of the sequence, not just the name of the table.

8.0 now offers the pg_get_serial_sequence function which may help you out.

> Does the JDBC-Driver implement the getGeneratedKeys() method?

No, see the many discussions of this in the archives, for example:

http://gborg.postgresql.org/project/pgjdbc/bugs/bugupdate.php?984

http://archives.postgresql.org/pgsql-jdbc/2004-09/msg00190.php

Kris Jurka



^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: How to get generated primary key?
  2005-02-19 17:15 How to get generated primary key? Sven Köhler <skoehler@upb.de>
  2005-02-19 20:21 ` Re: How to get generated primary key? Kris Jurka <books@ejurka.com>
@ 2005-02-20 16:48   ` Dave Cramer <pg@fastcrypt.com>
  0 siblings, 0 replies; 3+ messages in thread

From: Dave Cramer @ 2005-02-20 16:48 UTC (permalink / raw)
  To: Kris Jurka <books@ejurka.com>; +Cc: Sven Köhler <skoehler@upb.de>; pgsql-jdbc

Apparently there is work going on to support sql2003 generated keys.

On the upside you are guaranteed that they truly work now as opposed to 
some other db's.

Dave

Kris Jurka wrote:

>On Sat, 19 Feb 2005, [ISO-8859-15] Sven Köhler wrote:
>
>  
>
>>i know about the nextval and currval functions, but i don't like them, 
>>since they don't apply to tables. To get the generated key, you have to 
>>know the name of the sequence, not just the name of the table.
>>    
>>
>
>8.0 now offers the pg_get_serial_sequence function which may help you out.
>
>  
>
>>Does the JDBC-Driver implement the getGeneratedKeys() method?
>>    
>>
>
>No, see the many discussions of this in the archives, for example:
>
>http://gborg.postgresql.org/project/pgjdbc/bugs/bugupdate.php?984
>
>http://archives.postgresql.org/pgsql-jdbc/2004-09/msg00190.php
>
>Kris Jurka
>
>---------------------------(end of broadcast)---------------------------
>TIP 8: explain analyze is your friend
>
>
>  
>

-- 
Dave Cramer
http://www.postgresintl.com
519 939 0336
ICQ#14675561

^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2005-02-20 16:48 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2005-02-19 17:15 How to get generated primary key? Sven Köhler <skoehler@upb.de>
2005-02-19 20:21 ` Kris Jurka <books@ejurka.com>
2005-02-20 16:48   ` Dave Cramer <pg@fastcrypt.com>

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