PATH |
Pessimistic Locking in Sybase
Discussion
All Sybase versions prior to version 11.9 use page-level locking. Unlike a row-level lock, a page-level lock not only locks the row you selected, but also locks all other rows in the same page. Page sizes can be changed, but doing so may affect overall database performance.
EOF uses the HOLDLOCK clause when performing a select to enable Sybase's pessimistic locking. Suppose two users lock a record with the HOLDLOCK clause. If user A tries to update the record before user B, user A blocks until user B either saves his changes or reverts his changes. If user B attempts to save his changes, an exception is raised and his update fails, whereupon user A's update succeeds.
Suppose user A locks a record, but user B does not. If user B attempts to update that record, he blocks until user A saves his changes or reverts his changes. At this point, user B's update continues, and no exception is raised.
© 1999 Apple Computer, Inc.