Subject Re: [ib-support] Sequential running no using trigger and generator
Author junior
Thanks Ivan,

Emm.... my scenario here is that I assign sequential running no to a
document issued by users upon posting. So users won't get to know their
respective doc no until they post it, this is to avoid "wastage" of
generated doc no and also try to minimize "voids". But I am afraid that
sometimes users won't be able to commit to their transaction due to certain
errors (which is unlikely), so, I think it would be good to have a continuos
number in the db when users try to query the result, since my approach
somehow hints that they will get "continous numbers"

Best wishes,
jr

----- Original Message -----
From: "Ivan Prenosil" <prenosil@...>
To: <ib-support@yahoogroups.com>
Sent: Friday, August 17, 2001 7:12 PM
Subject: Re: [ib-support] Sequential running no using trigger and generator


> > I need a continuos running number to be inserted into a field, but every
time when there is any exception
> during posting, the generator will get incremented, so my current thought
is:
> >
> > 1. Create 2 generators, 1 to be called before insert, another to be
called after insert.
> >
> > 2. Create 1 generator, insert 0 or -1 or any arbitrary no into the
field, then call the generator to get
> the number.
> >
> > Which way is better, any unwanted side effects? Or is there better
ideas?
>
> Generating continuous numbers is much more complicated than one can think.
> If you search archives of IB forums, you will find lots of suggestions,
> but each of them has some problems. e.g.
> - your suggestion will solve the problem with failed insert statement,
> but it will not work when you rollback the transaction.
> - finding next value by SELECT MAX(... will not work reliably when more
users work simultaneously
> - retrieving next value from single row in additional table will cause lot
of update conflicts
> etc.........
>
> So first you should first state whenther you really need it (or just want
it to get nicer numbers),
> and what are your requirements (what is the reason for such demand).
>
> Ivan
> prenosil@...
> http://www.volny.cz/iprenosil/interbase
>
>
>
> To unsubscribe from this group, send an email to:
> ib-support-unsubscribe@egroups.com
>
>
>
> Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
>
>
>