View Single Post

   
  #3 (permalink)  
Old 04-08-2008, 03:03 PM
Pablo Sanchez
 
Posts: n/a
Default Re: Prevent multiple selects on a table

moh_muj@yahoo.com (Zia) wrote in
news:f5db6e5c.0310302009.5d545c12@posting.google.c om:

> HI All,
> I have got struck in a situation where 2 or more processes appear
> simultaneously read the data from a table and each one of them
> insert a new row into the same table.


Depending on the version of Sybase you have, you can solve this one of
two ways:

1) Use the IDENTITY type to generate the next ID
2) UPDATE my_table SET @my_val = max(id)+1, id = max(id) + 1 ...
--
Pablo Sanchez - Blueoak Database Engineering, Inc
http://www.blueoakdb.com
Reply With Quote