General information
Category:
Coding, syntax & commands
Title:
Getting a unique sequential ID for a record
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
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only