Re: Pessimistic locking with ODBC - HELP!!
Posted in 1997
Tim Kelly wrote: > > Hi All, > > Can anyone help? > > I am using Delphi 2 client-server (BDE vn 3.0), Openlink multi-tier ODBC > and Informix 5 SE. > I want (nay, NEED!) to be able to read and lock a row from a table - as per > 4GLs trusty: > "DECLARE CURSOR... SELECT....FOR UPDATE" > > However, my documentation states I can only get optimistic locking when > connecting to SQL databases. This will not be a popular choice with my > users (or me), who expect to read-with-lock, amend and post their updates. > > Does anyone have any suggestions? You can simulate reasonable well by FETCH-MODIFY-REFETCH-COMPARE and perform the update only if the record has not been changed. This scheme favors the swift of finger (to complete the update form) rather than the swift of foot (to get to the terminal first) and trades a "Record locked" message for a "Record has been updated by another user" message. At least it still prevents stomping on anothers work. Art S. Kagel