SLA - Silver (add years in quantity field) added to your shopping cart.

Pessimistic locking:

Table.Edit; // locks the record, no other client will be able to make

conflicting changes

try

 // set field values

 Table.Post;

except

 Table.Cancel;

 raise;

end;

Optimistic locking:

repeat

 Table.Edit; // just gets the current record version from the server

without placing a lock

 try

   // set field values

   Table.Post;

   break; // exit the repeat loop, record posted successfully

 except

   on E: EnxDatabaseError do begin

     Table.Cancel;

     case E.ErrorCode of

       DBIERR_OPTRECLOCKFAILED:

         { conflicting change... retry };

       DBIERR_OPTRECLOCKRECDEL: begin

         { record has been deleted... }

         raise;

        end;

     else

       raise;

     end;

   end;

 else

   Table.Cancel;

   raise;

 end;

until False;

Home | Site Contents | Documentation | NexusDB Manual V4 | Delphi Guide | Code Examples & Fragments