Lock Problem (OpenInsight 32-bit Specific)
At 07 APR 2009 10:48:01PM Robin Tinker wrote:
I have lock problem. I'm just beginner of OI so even though I searched still I couldn't solve. This program works well, but the problem is that system displays Lock error "The entry is locked and may not be modified. Do you wish to continue to view the entry?"
This message is my problem. How can I remove this message? Help me pls!!!!!
Open DICT to Dict.File else Return
Open Table to Data.File else Return
LOOP
Locked=FalseLock Dict.File, key, XC Thengosub read.keyLocked=Truegosub lock.okEnd Elsedelay(1)gosub Display.Retry.MessageEndUNTIL Locked=True
REPEAT
Write Seq.Key.Rec On Dict.File, key else Null
Unlock Data.File, Seq.Key Else Null
Unlock Dict.File, key else Null
return
*—————————————————————————
Read.Key:
Read Key.Rec From Dict.File, key then
Locked =TrueSeq.Key=Key.Recend else returnReturn
*———————————————–
Lock.OK:
LOOP
lock Data.File, Seq.Key, XC thenRead Next.rec From Data.File, Seq.Key else Key.OK=yesEnd elsedelay(1)gosub Display.Retry.MessageendUNTIL Key.OK=yes
Unlock Data.File, Seq.Key Else NullSeq.Key += 1REPEAT
return
At 08 APR 2009 04:39AM Warren Auyong wrote:
What happens if you get rid of the "XC" clause on the Lock statement?
At 08 APR 2009 05:48PM Robin Tinker wrote:
I couldn't see any difference. XC or not. I tried 02 too.
At 09 APR 2009 06:47AM Richard Bright wrote:
Robin,
Quick perusal of the code gives me some concern wrt the logic and lack of error trapping - but I could be wrong.
If you are pragmatic and just want to get the job done, you might like to try David Goddard's routine rgd_table_getNextID published in the OpenInsight code forum http://openinsight.wetpaint.com. At least comparing that code with what you have may be helpful.
At 10 APR 2009 09:49PM Eric wrote:
Change the message type to a timed message of zero seconds in SYSMESSAGES or wherever the message lives.
At 11 APR 2009 11:09AM Richard Hunt wrote:
It seems that within your main code you have the statement "LOCK DICT.FILE, KEY, XC THEN" within the LOOP, and the UNLOCK sentence outside the LOOP. This causes the same item to attempt a LOCK without it being UNLOCKED. I think the multiple attempts to LOCK without the coordinated UNLOCK is your problem.
If you wish to maintain the logic of your code then you will have to check the STATUS() variable to see if the lock was unsuccessful because of you holding the lock or not.
I suggest that you move the "LOCK DICT.FILE, KEY, XC THEN" sentence to before the loop so that it does not repeat itself.
At 13 APR 2009 09:19PM Robin Tinker wrote:
Hello Richard,
I changed my program to have exact same routine with David Goddard's.
I didn't say but It's working in network mode and the problem is second user can still get the same sequence number and with that horrible message the user can ignore the warning message and process his work and later complain he/she lost datas. I noticed that message is not from this program. I just don't understand how come the second user can get the same sequence number even though the records was locked.
At 13 APR 2009 09:22PM Robin Tinker wrote:
Hello Eric,
I tried find what you suggested, how to use from help. I couldn't find. Can you pls explain a little more for beginner?
At 13 APR 2009 09:25PM Robin Tinker wrote:
Hello Richard,
I changed my program to match lock and unlock inside the loop but it doesn't still work.
At 13 APR 2009 09:42PM Robin Tinker wrote:
Hello Richard,
I checked status(). If it's stand alone it works perfectly. If it's in network mode, the second user can get the same sequence number.
At 14 APR 2009 02:45PM Jared Bratu wrote:
It was explained to me, a record lock is less like a physical lock and more like a do not disturb flag.
Think of a hotel room door, the do not disturb sign doesn't prevent you from going in but it is a signal that you can choose to obey.
For example, given two stations, A and B. Station A can lock a record. Station B can ask to lock that same record but it will be denied. Only your code prevents Station B from writing to the record. When Station B finds the locked record it should either wait, or abort the routine, until it gets a lock on the record.
At 14 APR 2009 05:00PM Robin Tinker wrote:
I'm so stupid. Lock works perfectly. It was my mistake.
Thank to all.
At 14 APR 2009 05:05PM Robin Tinker wrote:
Locks work perfectly. It's just my fault.
Thank you everyone.