INSERT and get ID
От | Peter.Zoche@materna.de |
---|---|
Тема | INSERT and get ID |
Дата | |
Msg-id | 3617A3C21370D045B75C0A40A7A6530D0B37E199@ntexc2buc.do-office.buc.materna.com обсуждение исходный текст |
Ответы |
Re: INSERT and get ID
Re: INSERT and get ID Re: INSERT and get ID |
Список | pgsql-jdbc |
Hi! Say I have done the following: CREATE SEQUENCE myseq CREATE TABLE foo ( id INTEGER, val INTEGER, PRIMARY KEY( id ) ); Is there an easy way to get the id of the newly inserted data set? So if I do the following: String insert = "INSERT INTO foo (id, val) VALUES( nextval('myseq'), 5 )"; int count = statement.executeUpdate( insert ); I only get the row count of inserted rows. Do I have to query the database again to get the id? Or is there another way? I have tried statement.executeUpdate( insert, Statement.RETURN_GENERATED_KEYS); but I get an PSQLException saying that the feature of auto-generated keys is not supported. (using postgresql 8.0 JDBC3) I googled but I did only find PostgreSQL- specific hints, no one for JDBC. Thanks, Peter
В списке pgsql-jdbc по дате отправления: