Re: Dynamic Updating Problem
Posted in 1993
SSLeong writes: > >Problem : updating of dynamic data. >------- >User-A selects (Account-balance) with the intention of updating it later. >Following that, User-B selects with the same intention. > >So, if User-A updates the (Account-balance), User-B's update would produce >an incorrect final Account-balance. > >Current Solution : using a flag >---------------- >We have an (in_use_ind) field that a user sets when the record is being used. >Another user accessing the same record will see that it is locked and will not >use it. > >Current Problem with that Solution >---------------------------------- >1. The second user will be locked-out indefinitely. >2. A power failure will require a manual reset of the (in_use_ind). > >Looking For : >----------- >A solution which will allow many users to use the record and update it, >or give a warning if update is not possible because record had been changed >by another user. > > >I am thinking of using semaphores to keep track. >Has anyone such a semaphore routine ? or any better suggestions ? >Thanks ! > >contact : ssleong@csasoft.csam.MY If you are using an Informix server (you don't say in the posting) then there is no need to "reinvent the wheel" so to speak. Simply fetch your data using a cursor declared for update (I'm assuming you're using 4gl or ESQL/C). That will place an update lock on the row, which will allow other users to read the row but not update it or select it for update. Dave -- Disclaimer: These opinions are not those of Informix Software, Inc. ************************************************************************** "I look back with some satisfaction on what an idiot I was when I was 25, but when I do that, I'm assuming I'm no longer an idiot." - Andy Rooney