Cheryl - 'nest number'
Posted in 1993
} } When I create a table for use in a database, I tried to have } a unique numeric key to that table. } } for instance: } } I have a table with: } } table: nsn } nsnkey smallint } stocknbr char(15) } mfgpn char(18) } qty smallint } ....more field here } } table: next_n } nxt_desc char(15) } nxt_nbr smallint } } You could have a record for each type number you need. } } esql-c } } $ select nxt_nbr into $nxtn } from next_n where nxt_desc = "nsn_table"; } } /* with nxtn being the next sequential number */ } } $ insert into nsn values } ($nxtn, $stock, $mfg, $quantity, ...other fields) } } then whatever you select the nxt_nbr into } nxtn=nxtn+1 (whatever the syntax in your version, isql,4gl, esql-c) } or } $ update next_n set nxt_nbr to nxt_nbr + 1 where nxt_desc = "nsn_table"; } } Maybe the sample isn't the best in the world, but it is fairly simple } and is very quick. } Have you considered a data type of serial? That's what you are describing. cheers j. _____________________________________________________________________________ Jack Parker - Contractor |"Is it weakness of intellect birdie" Hewlett Packard, BSMC Boise, Idaho, USA|I cried, "or a tough little worm in jparker@hpbs2561.boi.hp.com |your little inside", with a shake of (208) 396-5388 (W) (208) 384-1623 (H) |his head he sadly replied: | "Oh willow, Oh willow, tit willow". _____________________________________________________________________________ Any opinions expressed herein are my own and not those of my employers. _____________________________________________________________________________