# Web DBI - Concurrent editing

- ## How to prevent updates overwriting each other?

  - You can use Optimistic Locking via 'qualified update':
    update table set ...
    where key = $old_key
    and field1 = $old_field1
    and field2 = $old_field2 and … for all other fields

- ## Check the update row count

  - If it's zero then you know the record has been changed or deleted by another process

- ## Note

  - Potential problems with floating point data values not matching due to rounding
  - Some databases support a high-resolution 'update timestamp' field that can be checked instead

Previous slide | Next slide | Back to first slide | View graphic version