Re: [SQL] begin/end/abort work for sequences? - Mailing list pgsql-sql

From Kyle Bateman
Subject Re: [SQL] begin/end/abort work for sequences?
Date
Msg-id 377BF9E4.975A808E@actarg.com
Whole thread Raw
In response to Re: [SQL] begin/end/abort work for sequences?  ("D'Arcy" "J.M." Cain <darcy@druid.net>)
List pgsql-sql
"D'Arcy J.M. Cain" wrote: <blockquote type="CITE">Thus spake Kyle Bateman <br />> Do you know if there is a
workaround? In my particular situation, it is critical <br />> that all instances of the sequence actually get
used. If a transaction is <br />> aborted, I lose an instance and everything gets messed up. <p>I had to solve this
oncein another RDBMS (Progress) and this is how I <br />did it.  I had a table of available sequence numbers consisting
oftwo <br />fields, a name and a number.  The table was seeded with 10 entries for <br />each required sequence
numbered1 to 10.  When I needed a sequence I <br />started a transaction and grabbed and locked the lowest numbered
record<br />for that sequence that wasn't locked.  I save the number then add 10 to <br />it.  If I abort the
transaction,the number remains unchanged.  Under <br />this scheme 10 users can be working on the same sequence without
locking<br />others out.  Numbers can be used out of sequence from time to time if <br />someone aborts but they all
getused eventually. <p>-- <br />D'Arcy J.M. Cain <darcy@{druid|vex}.net>   |  Democracy is three wolves <br /><a
href="http://www.druid.net/darcy/">http://www.druid.net/darcy/</a>               |  and a sheep voting on <br />+1 416
4242871     (DoD#0082)    (eNTP)   |  what's for dinner.</blockquote> Thanks for taking the time to reply! <pre>-- 
 
 ----------------------------------------------------
 Kyle Bateman       President, Action Target Inc.
 "Viva Yo!"         kyle@actarg.com (801)377-8033x101
 ----------------------------------------------------</pre>  

pgsql-sql by date:

Previous
From: Fomichev Michael
Date:
Subject: Re: [SQL] DISTINCT on multiple fields (fwd)
Next
From: webmaster
Date:
Subject: Re: [SQL] Beginner's headache of joins