Subject | Re: [firebird-support] One more sequence related question |
---|---|
Author | Nando Dessena |
Post date | 2008-02-15T08:50:11Z |
Fidel,
F> 1) The Invoice numbers have to be sequential, and no gaps are allowed
F> 2) There shall not exist a case where invoice2.timesaved >
F> invoice1.timesaved and invoice1.no > invoice2.no
F> In the demo I have created, this is no problem. If the transaction
F> fails, then I can always move the sequence back a number using
F> ALTER SEQUENCE SEQ_NAME RESTART WITH GEN_ID(SEQ_NAME, 0)-1. Now, on
F> the concurrent version, that will, obviously, not work. I could use
F> locking, but I don't think that is the best approach.
F> Can someone suggest a good approach to solve this?
I wouldn't use sequences for that. Serialization is required here,
IMHO.
Ciao
--
Nando Dessena
======================================================
I support Firebird, I am a Firebird Foundation member!
Join today at http://www.firebirdsql.org/ff/foundation
======================================================
F> 1) The Invoice numbers have to be sequential, and no gaps are allowed
F> 2) There shall not exist a case where invoice2.timesaved >
F> invoice1.timesaved and invoice1.no > invoice2.no
F> In the demo I have created, this is no problem. If the transaction
F> fails, then I can always move the sequence back a number using
F> ALTER SEQUENCE SEQ_NAME RESTART WITH GEN_ID(SEQ_NAME, 0)-1. Now, on
F> the concurrent version, that will, obviously, not work. I could use
F> locking, but I don't think that is the best approach.
F> Can someone suggest a good approach to solve this?
I wouldn't use sequences for that. Serialization is required here,
IMHO.
Ciao
--
Nando Dessena
======================================================
I support Firebird, I am a Firebird Foundation member!
Join today at http://www.firebirdsql.org/ff/foundation
======================================================