Lock/UnLock tables (AREV Specific)
At 08 JAN 1998 07:28:06PM Don Bakke wrote:
I'm struggling with placing a lock on an entire file. Record locks have never been a problem but this is the first time I've needed and tried to lock the table.
Here is my code:
Open "REPORT_BUCKET" to RBT then Lock RBT, ALL, 01, then Perform "CLEARTABLE REPORT_BUCKET (OS" end else Msg("|Unable to lock the Report Bucket table.|") If Status() EQ 1 then UnLock RBT, "" else Msg("|Unable to unlock the Record Bucket table.|") end end return end end else FsMsg() return end . . /* other code */ . . UnLock RBT, "" else Msg("|Unable to unlock the Record Bucket table.|") endWhen I run this the first time, it appears to lock okay and unlock okay because the code will run and I don't get any messages saying it couldn't lock or unlock the table.
The very next attempt, however, tells me that it can't lock the table. Status() is 0 (not even 1!) so nothing is working as expected.
So far this is only on a standalone station (so I can't even explain why a Status() of 0 is appearing) under Win95 using AREV 3.12.
Any ideas?
Thanks,
At 09 JAN 1998 03:51AM Andrew P McAuley wrote:
Well Don, I tried the following on OI and it worked just fine. My immediate inclination was to suspect that the unlock docs were misleading so I ignored them - RevSoft developers are at least consistent! So unlock works as lock.
Subroutine Don(DVoid)
Open "SYSREPOSWINS" to RBT then
Lock RBT, ALL, 01 thenCall Msg("", "Locked OK")end elseCall Msg("", "Couldn't be Locked")endend else
end
UnLock RBT, ALL Then
Call Msg("", "UnLocked OK")End Else
Call Msg("", "Couldn't be unLocked")end
Return
World Leaders in all things RevSoft
At 09 JAN 1998 09:39AM Don Bakke wrote:
Thanks, Andrew for testing this for me. Here are some further insights on this:
UnLock RBT, ALL Then
This is the key difference between your code and mine. Instead of the ALL keyword I am using "". The reason is because the documentation (in AREV and OI) says that for the UnLock command, the ALL keyword removes all locks set by this workstation. That is not what I want to do. I only want to remove the lock on this table which the "" parameter is supposed to do. So I suspect this is a bug from way back that has never been addressed. (I also find it interesting that the keyword ALL means something different with the Lock command than the UnLock command.)
Another problem is Status() being set to 0 in AREV when the workstation is attempting to lock the table but that workstation already has a lock on it. In OI, Status() is correctly set to 1. So again I suspect an old bug although this one got fixed in OI at some point.
Unfortunately, I need a mechanism whereby I can guarantee that an entire table will only be accessed by one workstation at a time. Do you suppose putting a lock on a particular column in the dictionary would do the job (kind of like how indexes get updated)?
Thanks,
At 09 JAN 1998 09:43AM Aaron Kaplan wrote:
Check out TB #2 about locking. Seems to me that you would pass in the same parms for an unlock as you would for a lock.
You might not want to do an unlock all in case you're not at level 1.
At 09 JAN 1998 10:18AM Andrew P McAuley wrote:
Donald
I suspect a difference between
Unlock ALLand
Unlock FileVariable,All
give it a try!
Toodles
World Leaders in all things RevSoft
At 09 JAN 1998 11:43AM Don Bakke wrote:
Andrew,
Okay, that makes sense. Thanks again for pointing me in the right direction.
Now the only issue remaining is the value of Status() problem in AREV, but I can work around that.