>Hiya Craig,
>
>Many thanks for the reply. I take note about 2 users appending records at the same time. I didnt consider that possibility, although that isnt causing my problem of duplicate keys since the record already exists.
>
>Using FLOCK seems an excellent idea and I will implement this in my stored procedures, but i'm still not sure why the original function failed and gave duplicate keys which is a little worrying.
>
>I consider 2 scenarios a possibility:
>
>1) When i UNLOCK the record it performs an implicit FLUSH, but i am wondering if its possible that another user creeps in and updates the record, hence giving a duplicate key, in between the implicit UNLOCK/FLUSH. I would assume though that flushing occurs before the unlocking. Anyway I will perform an explicit FLUSH before unlocking to remove this possibility.
Good idea, just to play it safe.
>
>2) RLOCK is failing in some way and returning .T. when not actually having gained a record lock. In this case the possibility of duplicate keys arise. Hence i will start using FLOCK. Have you any ideas if RLOCK is known to fail in this way under any conditions?
I've never seen nor heard of RLOCK() failing in this way.
>
>Again thanks for your reply Craig, I'm hoping it will resolve my problems.
>
>
>Paul.
Craig Berntson
MCSD, Microsoft .Net MVP, Grape City Community Influencer