How do I get an exclusive lock on a record... code is
FIND dcnew WHERE RECID(dcnew) = FixMeRecID EXCLUSIVE-LOCK.
if available dcnew then...
and in code here I try to change a value in dcnew I often get an error saying dcnew is in use by so-and so
why does this not work.
Are you taking this record of a browser?
Are you using no-lock in your browser?
no browser I just try to update that record and I get a record is locked error
The IF AVAILABLE test isn't going to do you any good if you don't use NO-ERROR. If someone already has the record when you try to lock it, you will get the error you describe.
i've had no-wait no-error on it same thing.. it is going through a for each loop at this time and updates records.... typically out of 500 or so updates 1 fails because the record is in use
COMPILE with LIST to look at your transaction scoping and, if that doesn't tell you, give us a bit more of the code ... there is something you aren't telling us. If you do a FIND EXCLUSIVE NO-ERROR and the record is AVAILABLE, then you have it locked until you release it so, either you aren't getting it in the first place or the scope of that lock isn't what you think it is and you are getting the error outside that scope when, perhaps, the EXCLUSIVE has degraded to SHARE.