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.