You'll want to generate a "sequence", setting an initial number and
an increment.
create sequence seq_name
start with 1
increment by 1
maxvalue 999999
nocycle
cache 20;
then you'll do something similar to this:
INSERT INTO table_name
( id_no, col1, col2 )
values
( seq_name.NEXTVAL, '$col1', '$col2' )
if you have few inserts and want to not have skipped sequence numbers, then
avoid using a cache, it tends to cause "gaps" (at least in our environment)
good luck!
PS: wait for the insert to get the nextval, then display it post-insert. not before, or you'll
get into trouble with non-uniqueness, which is what sequences are made to avoid :-) |