I am writing an order entry app and would like to implement multi user access as follows using Innodb:
1) The first person into an order (a record in tblOrder) gets read-write access.
2) Successive people get read-only access until first person gets out of the order and are warned about this before they try to open the order.
I've tried the following:
Problems:
1) Other records (other than ID = 1) seem to be blocked from updates so in other words, users editing other orders can't save their changes.
2) I don't know how I can tell that an order is locked before the user opens it. I know that updates are blocked but I need to warn the user about this before they make a bunch of changes with the expectation that they can save them.
3) I don't know how to release the lock on the record if the user makes no changes but exits the order.
It would be useful to be able to see what record locks are in place so I can learn the behavior a little better. Anyone know how to list what records are locked?
Any suggestions on a standard way of implementing this behavior?
1) The first person into an order (a record in tblOrder) gets read-write access.
2) Successive people get read-only access until first person gets out of the order and are warned about this before they try to open the order.
I've tried the following:
Code:
SELECT *
FROM tblOrder
WHERE ID = 1
LOCK IN SHARE MODE;
Problems:
1) Other records (other than ID = 1) seem to be blocked from updates so in other words, users editing other orders can't save their changes.
2) I don't know how I can tell that an order is locked before the user opens it. I know that updates are blocked but I need to warn the user about this before they make a bunch of changes with the expectation that they can save them.
3) I don't know how to release the lock on the record if the user makes no changes but exits the order.
It would be useful to be able to see what record locks are in place so I can learn the behavior a little better. Anyone know how to list what records are locked?
Any suggestions on a standard way of implementing this behavior?