Re: Next Serial value ?
Posted in 1998
On Sat, 29 Aug 1998 16:06:33 -0400, Eric Weaver <eweaver@intelihealth.com> 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. If I understand you correctly you say you want the serial value that will be used before you do an insert into the very table that contains the serial column in question. Whatever you want there is no way standard way of getting at the serial value that will be used. There may be some way to read it from one of the sysmaster tables, but I don't know how. However what we do is to create a separate table with nothing but a serial column. We do an insert in that and optain the serial value from that insert in the regular way (sqlca.sqlerrd[x] x beeing 1 for ESQL/C and 2 for 4GL or using dbinfo in a select statement). Then we use this value to insert in whatever table that needs a modified serial value (in our case simply a check digit, but it could be anything of course). You can delete all rows from this extra table at any time to keep it from growing. The next serial value is maintained outside the table data as you asume, so there is no need for even a single row to exist in the table between inserts. Nils Myklebust NM Data AS Norway E-mail: Nils.Myklebust@nmdata.com FAQ at: http://www.iiug.org/techinfo/faq/faq_top.html (Now with ODBC info under "Third party products".)