Peter.Zoche@materna.de wrote:
> 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?
Currently, yes. You can usually do some trickery with currval() to run
both an INSERT and a SELECT in the same statement and avoid an extra
round-trip.
> 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.
Right, this really needs server-side support before we can implement it
(INSERT ... RETURNING ... or similar)
-O