From: | "Michael Paesold" <mpaesold(at)gmx(dot)at> |
---|---|
To: | "Dave Cramer" <Dave(at)micro-automation(dot)net> |
Cc: | <pgsql-jdbc(at)postgresql(dot)org> |
Subject: | Re: Implementing JDBC3 methods (Was: JDBC and fetching theOID of an insert) |
Date: | 2002-09-18 21:43:14 |
Message-ID: | 002401c25f5c$6636e9e0$4201a8c0@beeblebrox |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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.
From | Date | Subject | |
---|---|---|---|
Next Message | pgsql-jdbc | 2002-09-18 21:44:33 | postgresql-7.2.2 jdbc compile failure |
Previous Message | Dave Cramer | 2002-09-18 20:54:31 | Re: Implementing JDBC3 methods (Was: JDBC and fetching the |