Re: Next Serial value ?
Posted in 1998
Eric Weaver wrote: > > Is there anyway to determine the next serial value to be used for a > specific table (without selecting max(<col>)+1). I figure this value > must be stored in a system table somewhere right? The server doesn't do > the max+1 calculation each time does it? > > I need this value BEFORE the insert so that I can use it to create a > hashed 24 byte code from it - then do the insert. Otherwise, I have to > do the insert, get the serial value, create my hashed code, and then do > an update. It would be more efficient to know the serial value before > hand. It is stored in a sysmaster table but DO NOT USE IT TO CALCULATE anything since by the time you have fetched the value and calculated the hash that serial number may have been used by another process for some other row. Best to insert without the hash, get the serial from the sqlca structure, calculate the correct hash and update the hash column in place. The update will happen in memory anyway will be instantaneous. Art S. Kagel