Re: Implementing JDBC3 methods (Was: JDBC and fetching
От | Dave Cramer |
---|---|
Тема | Re: Implementing JDBC3 methods (Was: JDBC and fetching |
Дата | |
Msg-id | 1032403598.21616.102.camel@inspiron.cramers обсуждение исходный текст |
Ответ на | Re: Implementing JDBC3 methods (Was: JDBC and fetching theOID of an insert) ("Michael Paesold" <mpaesold@gmx.at>) |
Список | pgsql-jdbc |
On Wed, 2002-09-18 at 17:43, Michael Paesold wrote: > Dave Cramer wrote: > > > Michael, > > > > What do you see as a generatedKey? you mean a serial type? > > I think so. I just read over the JDBC specification. It is not very > specific, about what is considered a generated key. I suppose it would be > any unique key (or field value?) that is automatically generated by the data > source / database. In postgresql, this could be a SERIAL, a field with a > default value from a SEQUENCE, of even an OID. This *could* also be a value > supplied by a user-defined trigger, depends on the point of view. I would think it would have to be a sequence, and an index This should be possible to find out through a select. ie find if the table has a default on an index column which selects nextval. > > The chapter about auto generated keys in the JDBC 3.0 specification (chapter > 13.6) start like this: > "Many database systems have a mechanism that automatically generates a > unique key field when a row is inserted." > They also have an example where they insert into an order table, the order > id is "generated". > > I think OIDs should also be classified as a generated key, they are unique > keys, identifying the inserted row. With OIDs it's quite easy, I think. But > what about serials (or sequence fields)? How difficult would it be to decide > wether a column/field is auto generated? I don't agree, they aren't index's, and they aren't unique > > >> int executeUpdate(String sql, int autoGeneratedKeys) > for this prototype it is hard to guess, what the programmer wants... > > >> int executeUpdate(String sql, String[] columnNames) > whereas here the caller can specify, what they would like to have returned. > It depends on the driver if it can/will supply the value for the columns, > though. > > > if you are writing for the driver then you can easily get the last > > inserted oid > > Right, I had a look at the code. > > Regards, > Michael > > P.S. When reading my emails, please be aware of the fact that English is not > my first language. > > > ---------------------------(end of broadcast)--------------------------- > TIP 2: you can get off all lists at once with the unregister command > (send "unregister YourEmailAddressHere" to majordomo@postgresql.org) > >
В списке pgsql-jdbc по дате отправления: