Re: Implementing JDBC3 methods (Was: JDBC and fetching theOID of an insert)

Поиск
Список
Период
Сортировка
От Michael Paesold
Тема Re: Implementing JDBC3 methods (Was: JDBC and fetching theOID of an insert)
Дата
Msg-id 002401c25f5c$6636e9e0$4201a8c0@beeblebrox
обсуждение исходный текст
Ответ на JDBC API Tests  (Al Sutton <al@alsutton.com>)
Ответы Re: Implementing JDBC3 methods (Was: JDBC and fetching
Список pgsql-jdbc
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.

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?

>> 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.


В списке pgsql-jdbc по дате отправления:

Предыдущее
От: Dave Cramer
Дата:
Сообщение: Re: Implementing JDBC3 methods (Was: JDBC and fetching the
Следующее
От: "pgsql-jdbc"
Дата:
Сообщение: postgresql-7.2.2 jdbc compile failure