Hi NoCoolHandle,
I'm planing moving my VFP to MSSQL Server. But before i move would like need some advices from your guys.
In one the application required
Pessimistic records locking ("Reserved Records").
Below is the field that use to reserved record:
field name type
locktim timestamp
lockuser Charater
In one of the entry program the user is allow to choose where the goods to store. When the user choose the locations. The record/s in the
location table is first check with the
"locktim" field. If the field is empty. then the record is available for others, else the
timestamp will be compare "Maxlocktiem" (~40 mininute). If timestamp greater than maxlocktime the record will be available for the user.
When user successful select the location a new timestamp will be update to the
locktim field. Within the "MaxlockTime" period this record is not available to others user.
Below is the algorithom is use :
Code:
1 IF not empty(locktim)
2 IF lockdt > maxlocktime
3 IF success Update the record time stamp
4 return .T.
5 else
6 return .F.
7 endif
8 else
9 return .F.
10 endif
11 endif
12 return .T.
When user save the records. It will compare
lockuser with the current
userid. The the userid change mean this record may be is
lockdt >maxlocktim has been expire the maximum reserve time already. So a error handling will pop up to ask the the user for action.
But in VFP once the record is reserve by the user it is lock pessimistic, by a command "Rlock". Even
line 2 code above will run but
line 3 will always fail, if the user still never close the application. (sound like stupid.. but is request by user.)
Is MSSQL server able to lock record like VFP ? Or should i change the locking strategy (or ask user to change their mind) ?
One more question, will this frequently update the
lockdt (timestamp col). Will slow down the server ? Because the time stap is update everytime the user make a selection on the location. Please kindly advice. Thanks.