Re: JDBC and fetching the OID of an insert

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: JDBC and fetching the OID of an insert
Date: 2002-09-18 14:04:13
Message-ID: 1032357854.26938.64.camel@inspiron.cramers
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

There is or was actually a method in the driver ResultSet.getLastOID
which allowed you to do this.You will have to cast the resultset into a
AbstractJdbc(x)ResultSet, where x is the version; but Daryl's way is
much better since oid's can wrap, and there is a possiblity that they
don't exist ( you can turn them off in postgres).

Dave

On Wed, 2002-09-18 at 09:36, Michael Paesold wrote:
> Hi,
>
> Does anyone of you know, how to get the OID of the just inserted Row after
> stmt.executeUpdate("INSERT... ")? I hope this is possible at all!
>
> If it's not, I would be willing to implement getGeneratedKeys() to return at
> least the OID of an insert. Assuming that would be possible and exceptable?
>
> (Btw. am I correct that the only way to get a value for a sequence via JDBC
> is to "SELECT currval('...')" resp. "SELECT nextval('...')"?)
>
>
> Best Regards,
> Michael
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 4: Don't 'kill -9' the postmaster
>
>

In response to

Responses

Browse pgsql-jdbc by date

  From Date Subject
Next Message Michael Paesold 2002-09-18 14:15:40 Re: JDBC and fetching the OID of an insert
Previous Message Daryl Beattie 2002-09-18 13:53:44 Re: JDBC and fetching the OID of an insert