Re: Sequence Numbers

From: Tommy Wareing <p0070621_at_brookes.ac.uk>
Date: 1995/04/05
Message-ID: <3luana$6p8_at_cs3.brookes.ac.uk>#1/1


In article <Pine.HPP.3.91.950404171303.9349A-100000_at_stimpy.mfa.com>, Dave Erickson says...
>My question at this point is, do you need the mathematic value of the
>sequence number, or are you just trying to generate a unique identifier?
>If you just need uniqueness, why self-impose the constraint of reading
>this number into an unsigned long? C offers plenty of flexibility as
>far as string manipulation; I would think you would want to read
>anything like this into a character array.

Indeed. We use 14 digit UIDs, and my PRO*C stuff always reads them into 15 character arrays. The main trick is whether they are left or right padded (if you make the mistake of using fixed width variables)

>BTW, Oracle DOES generate a guaranteed unique identifier for each row
>you insert, called 'rowid'. It's Oracle-specific, so if you're trying
>to stick to generic SQL, it's probably not a good idea, but if you're
>that concerned about getting a unique id per row, take the unique
>constraint off your primary key, and rely on this. That would be a
>pretty unorthodox approach for me, as well. I've never done it. But it
>does provoke thought...

The rowid can change if the row is deleted and re-inserted. So don't rely on it being constant.

-- 
 _________________________   __________________________________________
/  Tommy Wareing          \ /  I've been looking for an original sin,  \
|  p0070621_at_brookes.ac.uk  X   One with a twist and a bit of a spin    |
\  0865-483389            / \     -- Pandora's Box, Jim Steinman       /
 ~~~~~~~~~~~~~~~~~~~~~~~~~   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Received on Wed Apr 05 1995 - 00:00:00 CEST

Original text of this message