Обсуждение: Re: [GENERAL] Sequences do not obey transactions...

Поиск
Список
Период
Сортировка

Re: [GENERAL] Sequences do not obey transactions...

От
Ryan Kirkpatrick
Дата:
On Wed, 21 Jun 2000, Haroldo Stenger wrote:

> This issue has been asked & answered MANY times, once a week perhaps. I'll copy
> here what a folk answered once

    Hmm.. Then if the email archive searchs on the web site had been
working I would not have had to was the list's time. <subtle hint to the
maintainer of the email list archives :>
    As for the comments by people that pgsql's sequence behavior is
well documented, please tell me where! I have looked through the HTML does
and the FAQ that comes with Pgsql 7.0.2 and found no mention of it.

> "You can't.  Sequences are not designed for continuity, they are designed for
> uniqueness.

    Now that I think about it (again w/other people's explainations
taken into account) pgsql's behavior now makes sense to me. I was just
looking for a continuous sequence of unique numbers and thought a sequence
might be handy. Guess not. :( Thanks for everyone's explaination.

> Haroldo Stenger wrote:
> > And I add one of my own: It is not really necessary to have continuity in nearly
> > all apps. Your question is valid anyhow, but ask yourself: How does Oracle
> > resolve this? How would I program it myself by hand? And there you'll understand
> > the issue deeply.
>
> How funny it is to quote myself :9  I'd like to add this: When one has to number
> paper forms (invoices for instance), one must be careful about holes in
> sequences. What I do, is to have two sequences. One for the user, and one for
> the system. When the user has confirmed all her data, I'll COPY to another table
> the data, which NOW doesn't have a chance to cancel. Well, not so sure, but 99%
> of aborts, are user aborts. So this may help.

    That is similar to what I was attempting to do. I am making an
inventory database where each piece of computer equipment has a unique
number assigned to it. A sequence would save me having to figure out what
number was next. But if it had holes in the sequence, then I would end up
wasting the sequential labels I had already printed. :(
    Given my situtation, I think I will just use the label sheet to
tell me which number is next and enter it in from there. Low-tech, but
should work. :)

> Note to Bruce (or current FAQ mantainer): Please, add both the answer to the
> very question, and this addition of my own to the FAQ.  I would have loved to
> find it somewhere, when I didn't know what to do.

    Yes, please do. I always search the documentation and email
list archives (if available) before asking a question. Guess in this case
I hit a question that fell through the cracks before making it into the
FAQ.
    Once again, thanks for everyone's help.

---------------------------------------------------------------------------
|   "For to me to live is Christ, and to die is gain."                    |
|                                            --- Philippians 1:21 (KJV)   |
---------------------------------------------------------------------------
|   Ryan Kirkpatrick  |  Boulder, Colorado  |  http://www.rkirkpat.net/   |
---------------------------------------------------------------------------