i'm using select sql (DB2 on IBM i) to read a record from database and show it into a form where an user can modify and update it!
now i need that if an user is viewing this record, at the same time another user can only view but not update the same racord!
how can i do it? ther is a way to select this record allocating (or blocking) the record to avoid an update at the same time? (also if there is same php instruction to do it)
(for example i working with RPG language program where i use CHAIN instruction that alloc record to prevent this problem)
thanks!
In my experience you need to avoid going down this route if you possibly can.
Yes it is possible to lock the record, but how long do you intend to keep the lock? What happens if your locking user goes for a long lunch before hitting 'save'?
Faced with the problem you have, I would look at doing a read check of the record before updating. If you find it has been changed by another user you can flag this up or work in some logic to change only modified fields.