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