Subject | One more sequence related question |
---|---|
Author | Fidel Viegas |
Post date | 2008-02-15T08:36:41Z |
Hi again,
I have created a single user POS just to show the client how it is
going to work, and the requirements for it are the following:
1) The Invoice numbers have to be sequential, and no gaps are allowed
2) There shall not exist a case where invoice2.timesaved >
invoice1.timesaved and invoice1.no > invoice2.no
In the demo I have created, this is no problem. If the transaction
fails, then I can always move the sequence back a number using
ALTER SEQUENCE SEQ_NAME RESTART WITH GEN_ID(SEQ_NAME, 0)-1. Now, on
the concurrent version, that will, obviously, not work. I could use
locking, but I don't think that is the best approach.
Can someone suggest a good approach to solve this?
Thanks in advance,
Fidel.
I have created a single user POS just to show the client how it is
going to work, and the requirements for it are the following:
1) The Invoice numbers have to be sequential, and no gaps are allowed
2) There shall not exist a case where invoice2.timesaved >
invoice1.timesaved and invoice1.no > invoice2.no
In the demo I have created, this is no problem. If the transaction
fails, then I can always move the sequence back a number using
ALTER SEQUENCE SEQ_NAME RESTART WITH GEN_ID(SEQ_NAME, 0)-1. Now, on
the concurrent version, that will, obviously, not work. I could use
locking, but I don't think that is the best approach.
Can someone suggest a good approach to solve this?
Thanks in advance,
Fidel.