Re: Implementing JDBC3 methods (Was: JDBC and fetching

From: Dave Cramer <Dave(at)micro-automation(dot)net>
To: Michael Paesold <mpaesold(at)gmx(dot)at>
Cc: "pgsql-jdbc(at)postgresql(dot)org" <pgsql-jdbc(at)postgresql(dot)org>
Subject: Re: Implementing JDBC3 methods (Was: JDBC and fetching
Date: 2002-09-19 02:46:37
Message-ID: 1032403598.21616.102.camel@inspiron.cramers
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(at)postgresql(dot)org)
>
>

In response to

Responses

Browse pgsql-jdbc by date

  From Date Subject
Next Message Dave Cramer 2002-09-19 09:25:01 Re: Implementing JDBC3 methods (Was: JDBC and fetching
Previous Message Dave Cramer 2002-09-19 02:43:22 Re: multiple users accessing database