Posted: Mon Jul 23, 2007 1:11 am Post subject: ESQL Database Insert Retreive Auto ID
Acolyte
Joined: 18 Oct 2006 Posts: 65
Hi,
I have a DB2 table where every row is automatically assigned a row ID. Does anyone know if it is possible to retrive this ID when I call an 'INSERT INTO' esql call?
I've always had to run a passthru to call the DB specific function to return the last ID _________________ I am *not* the model of the modern major general.
Posted: Mon Jul 23, 2007 1:59 am Post subject: Re: ESQL Database Insert Retreive Auto ID
Padawan
Joined: 08 Oct 2004 Posts: 1905 Location: Dubai
Hi kayhansefat,
kayhansefat wrote:
I have a DB2 table where every row is automatically assigned a row ID. Does anyone know if it is possible to retrive this ID when I call an 'INSERT INTO' esql call?
No, I don't think this can be done...
If you have inserted unique fields in the insert, then you can do a SELECT again and find the row ID...
Else make a stored procedure (which internally will do the same thing) and return the new row ID.
There is a way to find the last inserted index id but if you have multiple flows or apps inserting into the table, then this might not be so reliable...
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum