Question How to block 2 users from accessing the same order code at the same time?

tuyennguyen

New Member
I am a newbie,
I have customized and compiled a program on QAD. However, I am having a problem when 2 users are using the program to access an order code at the same time.
How to prevent user A from accessing the order code while user B is accessing it?
 
If user A has an exclusive-lock on the relevant record then user B will not be able to access it.

Your could would be something like this:

Code:
find orderCode exclusive-lock where orderCode = 123 no-wait no-error.
if locked( orderCode ) then
  do:
    message "sorry user B, but this orderCode is being updated, please try again later".
    return.
  end.
 else
  do:
    /* do whatever it is that you are wanting to do with the orderCode if you are "user A" */
  end.
 
How to prevent user A from accessing the order code while user B is accessing it?
I think you should be more specific about what you mean by "access". That could be read-only or read/write. Multiple users can read records simultaneously without issue. But, as Tom said, only one user at a time can obtain an exclusive lock on a record. Your data-access statements (e.g. find, for, etc.) should always explicitly specify the required lock strength.

It might help to explain what you want your program to do, or what you mean by "I am having a problem", and show some sample code.
 
I am a newbie,
I have customized and compiled a program on QAD. However, I am having a problem when 2 users are using the program to access an order code at the same time.
How to prevent user A from accessing the order code while user B is accessing it?As a prim
 
As a practice, always use no-lock unless you are updating or deleting the record.

Code:
For each ordercode no-lock:
      /* Do whatever you want to do */
End.

Code:
Find ordercode where ordercode.order-code = "123" no-lock no-error.
If available ordercode then do:

End.
Else do:

End.
 
Back
Top