Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Broken ID value...
Message
From
10/03/2004 10:01:24
Dmitry V.Glouzdov
LUKOIL (Nizhny Novgorod)
Nizhny Novgorod, Russia
 
 
To
10/03/2004 09:20:28
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00884594
Message ID:
00884818
Views:
15
Data buffering is disabled.

FUNCTION GetNextID &&only idea
LPARAMETER m.sTableName
USE MaxIDList in 0 SHARED
SELECT MaxIDList
LOCATE FOR UPPER(ALLTRIM(TABLENAME))==UPPER(ALLTRIM(m.sTableName))
IF NOT FOUND()
** skiped
ELSE
IF NOT LOCK()
** skiped
ELSE
REPLACE MaxID WITH MaxID+1 IN MaxIDList
LOCAL m.nNewID
m.nNewID = MaxIDList.MaxID
UNLOCK
RETURN (m.nNewID)
ENDIF
ENDIF
ENDFUNC


>How are you doing locking to prohibit two people from getting the same value? Is the ID table buffered?
>
>
>>I save last ID in special table. Next ID will be as LastID+1.
>>
>>
>>>How are you generating the IDs?
>>>
>>>
>>>>Hi!
>>>>Have a problem with primary ID field in a table. I shall be glad if you will help.
>>>>
>>>>Legend:
>>>>VFP 5.0, Win2000 and about 10 very active users.
>>>>
>>>>We have a table with primary key on ID field N(13,0).
>>>>The table is consist of 400`000 records. Every day users add 5000 new rows in this table.
>>>>
>>>>Every day (!!!) programmer find 2-5 broken ID value (only in ID field).
>>>>Good ID value looks like 3010000001234.
>>>>Broken ID value looks like |010000001234 or 3|10000001234 (character symbol in first or second position in NUMERIC field). VFP understand this bad ID as 0 and 3. And it means that every day programmer find in the table _several_ rows with the same ID=0 (or ID=3) – the purpose of primary key is not work. Transaction mechanism was not help.
>>>>
>>>>The main trouble is: except this work place there are 16 similar sites with 2-5 users and 1-2 broken ID for a week (…and without local support).
>>>>
>>>>Need idea!
>>>>Thank you!
* Dim-Dim *
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform