[lug] Fwd: Simple counter?

Michael J. Hammel mjhammel at graphics-muse.org
Fri May 24 09:44:23 MDT 2013


On Fri, 2013-05-24 at 09:39 -0600, Jeffrey S. Haemer wrote:

> I want something that returns me sequential integers.  I ask it, I get
> a 1.  Three more times?  I get 2,3,4.  You ask it, you get 5, I ask
> again, I get 6, and so on.  If we both call it at the same time, we
> should *not* get the same number.

It's been awhile since I've used it, but I think MySQL has a field that
is auto-incrementing.  Not sure about being able to read it without it
updating, though.  Something tells me that there may be configurable
options for such a field since its a fairly common need.  

The nice thing I remember about this is that all accesses to it are
serialized, so we can both read it and the first one it gets the first
increment and the next one in gets the next increment.

-- 
Michael J. Hammel <mjhammel at graphics-muse.org>




More information about the LUG mailing list