Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Getting a unique sequential ID for a record
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
Getting a unique sequential ID for a record
Miscellaneous
Thread ID:
00812087
Message ID:
00812087
Views:
38
The following code was written for VFP5 a few years ago. Either the customer never noticed there was a problem, or it's just started acting up, but when I was testing it last week, it kept ending up with duplicate record ID.
...
set deleted on
set reprocess to 30 seconds
use sel_control in 0 exclusive && this is a single record table
current_request_id=sel_control.next_request
replace sel_control.next_request with current_request_id+1
use
close all
set exclusive off
...
later on in the code
* Create the main request row for the request_id
m.request_id = m.current_request_id
m.fieldxxx ....
m.fieldyyy = ... etc.
...
insert into sel_request from memvar
At this point it fails sometimes, and will not do the insert, because request_id which is supposed to be a unique field in this table ahs already been used. However, the first piece of code should have incremented it by one, each time.

This was failing, when only one user was on the system, so it's not from too many multiple users.
Next
Reply
Map
View

Click here to load this message in the networking platform