[prev in list] [next in list] [prev in thread] [next in thread] 

List:       sapdb-general
Subject:    RE: How to get the id of the last inserted row ?
From:       "Zabach, Elke" <elke.zabach () sap ! com>
Date:       2003-07-10 10:23:45
[Download RAW message or body]

Marc-Olivier Meunier wrote:

> 
> Hi all
> 
> I'm looking for a way to get the id of the last inserted row 
> in a table
> In fact, i would like to know if there is something with sessions when
> inserting a row.
> For example : i insert a row in a table which contains a SERIAL(1)
> default value for the id.
> If the next instruction is SELECT * FROM mytable WHERE rowno < 2 ORDER
> BY id DESC
> Will i get my last inserted row or not ? Considering that my db is
> linked to a web server with dozens query at the same time.

NO

> 
> Is there any other trick if this doesn't work ?
> Is a dbproc executed in a row or is it possible that two dbproc are
> executed at the same time ?

Why don't you use that feature described in the howto:
http://www.sapdb.org/7.4/how_tos/numbergen/datentypserial_eng.htm
and discussed (how many times??) in the list and now being in the archive?

And if you have the id, then you can pick YOUR last row.

Elke
SAP Labs Berlin
_______________________________________________
sapdb.general mailing list
sapdb.general@listserv.sap.com
http://listserv.sap.com/mailman/listinfo/sapdb.general
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic