Re: Synthesize support for Statement.getGeneratedKeys()?
От | Ken Johanson |
---|---|
Тема | Re: Synthesize support for Statement.getGeneratedKeys()? |
Дата | |
Msg-id | 45B1AFC2.5060900@kensystem.com обсуждение исходный текст |
Ответ на | Re: Synthesize support for Statement.getGeneratedKeys()? (Ken Johanson <pg-user@kensystem.com>) |
Список | pgsql-jdbc |
> > If someone has pointers to where the augmentaion code should be placed > (org.tgresql.jdbc3.Jdbc3ResultSetMetadata I presume), and also the > protocol (separate query to the server?, or append RETURNING clause to > the DML?). > > Also I cant remember - is it true that when inserting multuple VALUES, > that only the first (or last) SEQUENCE can be retrived, or can I > populate a resultset using the RETURNING data from by the server? > Answering my own question here... sort of :) http://www.postgresql.org/docs/current/static/sql-insert.html In the case of inserting multiple values (say 3 rows), is there a clever way to get the last 3 sequences via native SQL? Or would the JDBC code need to synthesize them?: (very simplified) ...exec rs.next();//single key returned Object id = rs.getObject(); Object[] keys = new Object[insertedRowCount]; for (; keys.length; i++) keys[i] = increment(id); myPGResultSet.populate(userDeclaredKeyNameOrIdx, keys);//hypothetical - i didn't look at the API yet, sorry
В списке pgsql-jdbc по дате отправления: