Re: Sequences do not obey transactions...

From: Ryan Kirkpatrick <pgsql(at)rkirkpat(dot)net>
To: pgsql-general(at)postgresql(dot)org, pgsql-sql(at)postgresql(dot)org
Subject: Re: Sequences do not obey transactions...
Date: 2000-06-23 00:36:34
Message-ID: Pine.LNX.4.10.10006221825070.10276-100000@excelsior.rkirkpat.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-sql

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/ |
---------------------------------------------------------------------------

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Richard Harvey Chapman 2000-06-23 02:52:41 Inheritance question
Previous Message Stephan Richter 2000-06-23 00:03:11 Conditions in PostGres SQL

Browse pgsql-sql by date

  From Date Subject
Next Message Ed Loehr 2000-06-23 01:55:32 Re: timespan casting
Previous Message Jeff MacDonald 2000-06-22 23:46:30 timespan casting