Inserted recored ID

Hi.

I am using a JDBC Insert adapter.

It adds rows to a table where an ID field ( the only PK) is generated by the table, it is not passed as input to the adapter.

Is there a way for the adapter to return the ID generated for the inserted row?

:confused:

1 Like

Guess, its not workable in same insert call :frowning: lets see if someone else has any ideas.

Hello

Soon after the insert sql(or anywhere before you do another insertion)you can use ‘Select Identitiy’ in your SQL to retrieve the last inserted identity key.
I guess this is same as doing it in the same SQL(if its at all possible)

thanks
Anil

What database are you using?

DB2 provides a SELECT FROM INSERT construct that does what you’re looking for.

Oracle has PL/SQL that could be used in a stored proc that can use INSERT…RETURNING construct. Then your service could call that proc.

Other DBs may have similar facilities.

The risk with the IDENTITY feature is that is probably not safe in an environment using concurrent inserts.

Is it a SEQUENCE NUMBER generated by database?

If so you can use SEQUENCE_NUMBER attribute… to get current value of inserted row…

–Shaik