Subject | Re: [Firebird-Java] How can I tell what row has been inserted into Firebird db via JSP |
---|---|
Author | Mark Rotteveel |
Post date | 2012-01-26T12:37:03Z |
On Thu, 26 Jan 2012 12:07:46 -0000, "grip_2ls" <neil.thompson@...>
wrote:
getGeneratedKeys() (in combination with the specific execute methods that
are defined in JDBC to support this functionality).
That functionality is however not available in Jaybird 2.1.6 IIRC, but -
with Firebird 2.0 or higher - you can use 'INSERT ... RETURNING
<your-primary-key-field>' and execute that as a query (eg executeQuery)
instead of an update. The returned resultset will then include the primary
key that was generated (which is almost identical to what Jaybird 2.2 will
do for the getGeneratedKeys() functionality).
Mark
wrote:
> I am using executeUpdate(query) to insert a row into a Firebird databasenot.
> table and while this works all it tells me is whether it has worked or
>be
> What I need to know is WHAT row was inserted i.e. when the record is
> inserted a unique primary key and I need to know this ID so that it can
> referred to in later statements.Jaybird 2.2 will add support for retrieval of the generated key using
>
> Is this possible to do and if so how?
getGeneratedKeys() (in combination with the specific execute methods that
are defined in JDBC to support this functionality).
That functionality is however not available in Jaybird 2.1.6 IIRC, but -
with Firebird 2.0 or higher - you can use 'INSERT ... RETURNING
<your-primary-key-field>' and execute that as a query (eg executeQuery)
instead of an update. The returned resultset will then include the primary
key that was generated (which is almost identical to what Jaybird 2.2 will
do for the getGeneratedKeys() functionality).
Mark