dbTalk Databases Forums  

D3/linux getting unique system wide ID's

comp.databases.pick comp.databases.pick


Discuss D3/linux getting unique system wide ID's in the comp.databases.pick forum.



Reply
 
Thread Tools Display Modes
  #21  
Old   
Lucian
 
Posts: n/a

Default Re: D3/linux getting unique system wide ID's - 10-19-2006 , 02:48 AM






Dale,
The following subroutine generates a significant number of system wide
unique numbers.
On my system, AMD 3000 & jBASE, creates about 200K numbers per second.
It relies on the following:
A common file that is visible from all accounts.
A record in this file named UNIQUE.
Because the named common is set for the duration of the session, the
above record is processed only once, the first time this routine is
called.
Each time the routine is called there is a number X unique to each
session ever logged and a second number Y that is unique to the current
session.
To preserve uniqueness you have to put a delimiter between X and Y or
you have to use a fixed format expression.
My choice is fixed format.
In this case X starts from 1,000,000,000 and Y from 10,000,000 which in
practice ensures that the unique number is allways 18 characters long
and has no leading zeros.
Even if you have 100,000 sessions a day, the routine ensures X
uniqueness for the next 245 years.
One advantage of this routine versus SYSTEM(19) is that the numbers are
sequential for the duration of the session and are date and time
independent.


SUBROUTINE GET.UNIQUE(N)
* 2006 - Lucian Pata

COMMON /UNIQUE/ X, Y

IF ASSIGNED(X) ELSE
OPEN '..\COMMON\TABLES' TO FILE ELSE STOP
READU X FROM FILE, 'UNIQUE' ELSE X = 10^9
X += 1
WRITE X ON FILE, 'UNIQUE'
CLOSE FILE
Y = 10^7
END
Y += 1

N = X:Y
RETURN
END


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.