Newsgroups: comp.lang.smalltalk,comp.databases.object
Path: cantaloupe.srv.cs.cmu.edu!bb3.andrew.cmu.edu!nntp.sei.cmu.edu!news.cis.ohio-state.edu!math.ohio-state.edu!uwm.edu!news-peer.gsl.net!news.gsl.net!news.mathworks.com!fu-berlin.de!golden-gate.owl.de!uni-paderborn.de!news.rwth-aachen.de!news.rhrz.uni-bonn.de!RRZ.Uni-Koeln.DE!news.gtn.com!blackbush.xlink.net!ins.net!heeg.de!hmm
From: hmm@heeg.de (Hans-Martin Mosner)
Subject: Re: Gemstone -- need sequential unique number
Message-ID: <DxGn2A.IM3@heeg.de>
Followup-To: comp.lang.smalltalk,comp.databases.object
Sender: uucp@heeg.de
Organization: Georg Heeg Objektorientierte Systeme, Dortmund, FRG
X-Newsreader: TIN [version 1.2 PL2]
References: <50mvmq$4hh@loki.tor.hookup.net> <50ooqf$5hp@hermes.is.co.za> <32304691.F96@iconcomp.com>
Date: Mon, 9 Sep 1996 10:13:22 GMT
Lines: 44
Xref: glinda.oz.cs.cmu.edu comp.lang.smalltalk:43229 comp.databases.object:11254

Bill Gooch (bill@iconcomp.com) wrote:
: Rudi Engelbrecht wrote:
: > 
: > quenton@Cherniak.ON.CA (Dennis Smith) wrote:
: > 
: > >I am working on accounting/customer-order (etc etc) designs
: > >using gemstone and visualworks.
: > 
: > >An obvious need is to be able to obtain an customer order
: > >number, or purchase order number.  Such numbers are
: > >roughly sequential (1,2,3,4,...).  I say roughly, because
: > >one might get a gap where a user created an order then
: > >killed it.
: > 
: > >My problem is how to obtain the number?  It must be unique,
: > >I don't know at the start of a transaction that I will need it
: > >or how many I will need.
: > 
: > >I might run a parallel session which could then lock/update/commit
: > >a counter object, but that would require 2 sessions per user.
: > ....
: > Have you had a look at the class called RcCounter?

: Ah, very good.  The stuff I did on this was prior 
: to the inclusion of the RC classes.  This is almost 
: surely the right way to go for this in GemStone - 
: much simpler than any alternative is likely to be.
:  

Beware, RcCounter is not designed for unique key generation but for
counting things like inventory etc.

For unique key generation, GemStone 5.0 provides the method
   System _sharedCounter: n incrementBy: i
where n is in the range 0..1899, so you've got plenty of counters
to play with. Note that this feature depends on the shared page
cache, so I don't know whether it is applicable to your situation.

Hans-Martin
--
+--- Hans-Martin Mosner -------- Senior Smalltalk Guru ---+
| These opinions are entirely ficticious.  Any similarity |
| to real opinions is purely coincidental and unintended. |
+--- <hmm@heeg.de> ------ URL:http://www.heeg.de/~hmm/ ---+
