Re: Taking a serial number?
Posted in 2001
Rafael Padilla wrote in message <95qbo9$ck6$1@nnrp1.deja.com>...
>
>I like to know if is it possible increment
>a serial value for a particular table in a
>store procedure?
>
>This is to reserve a number that could be used or not.
Sounds like a complicated logic, but I'll comment no more on that!
Easiest way to reserve a serial is:
insert into tab (0, blah, blah, blah)get the value of the new serial number
delete from tab where key = new_serial_number
and then later you can say
insert into tab (new_serial_number, blah, blah, blah)
Of course, the blah blah blah of the first insert will have to be sufficient
to put dummy values into any columns that are NOT NULL.
Stored memory of serial numbers is incremented at every insert and nothing
unwinds that, not even a rollback work.