Home    |    Concepts   |   API   |   Samples
Concepts > Schema Objects > Locking
Table row locks

A row lock is a persistent flag recorded for a row in an ArcSDE registered table that indicates that only the user placing the lock may delete, row lock, or update that row. Row locks are stored in a separate lock table. A registered table must have a valid integer row_id column, maintained by ArcSDE, which is set by calling SE_reginfo_set_rowid_column and have the SE_REGISTRATION_HAS_ROW_LOCKS bit set in its object mask by calling SE_reginfo_set_rowlocks to allow rowlocking operations. You must call SE_registration_create or SE_registration_alter for your SE_REGINFO setting to take effect.

There are two basic techniques to perform a row lock operation on a registered table.

  • Use the set of SE_table_* functions—Using the set of SE_table_* functions, an array of row_ids is passed for adding or removing locks.
  • Perform row lock as a constraint on an ArcSDE stream—Stream-based row locks work like a combination of stream logging and stream versions; the process happens as a side-effect of other operations (query, insert, or update), and the constraints can be both input filters and output filters. This is managed directly on a stream by calling the function SE_stream_set_rowlocking to setup the row locking operation flags.

Row locks affect who is allowed to delete or update the existing rows for the registered table. If a row is locked by a user other than the one currently connected, SE_stream_delete_row, SE_stream_set_row, SE_stream_flush_buffered_writes, or SE_stream_execute will return SE_LOCK_CONFLICT.

The SE_stream_set_rowlocking function is called for setting the row locking environment for the specified stream. It remains in effect until the stream is closed with reset TRUE or until the stream is freed.

Row locking operation flags on a stream

  • SE_ROWLOCKING_LOCK_ON_QUERY—All rows selected by SE_stream_fetch_row(), SE_stream_query(), or SE_stream_query_logfile() will be row locked. If any of the rows selected are locked by other users, then no rows will be locked. Rows already locked by the current user will not cause failure. At the start of the query, the lock table will be locked with an underlying DBMS lock. At the completion of the query, a COMMIT will be performed to preserve the row locks.
     
  • SE_ROWLOCKING_LOCK_ON_INSERT—All new rows inserted by SE_stream_insert_table() will automatically have a row lock entry inserted for them at the same time.
     
  • SE_ROWLOCKING_LOCK_ON_UPDATE—All rows modified by SE_stream_set_row(), SE_stream_update_row(), or SE_stream_update_table() have a row lock entry made for them at the same time.
     
  • SE_ROWLOCKING_LOCK_ONLY—No actual features are returned by query operations, only the row locks are placed. If requested by SE_stream_set_logfile(), locked rows are logged.
     
  • SE_ROWLOCKING_UNLOCK_ON_QUERY—All rows selected by SE_stream_fetch_row(), SE_stream_query(), or SE_stream_query_logfile() will have any row locks owned by the current user removed. At the completion of the query, a COMMIT will be performed to preserve the changes to the row locks.
     
  • SE_ROWLOCKING_UNLOCK_ON_UPDATE—All rows modified by SE_stream_set_row(), SE_stream_update_row(), or SE_stream_update_table() have their corresponding row lock entry (if any) removed at the same time.
     
  • SE_ROWLOCKING_FILTER_MY_LOCKS—This is a query filter, affecting SE_stream_fetch_row(), SE_stream_query(), and SE_stream_query_logfile(). Only those features locked by the current user are returned unless other lock filter options are selected; they are additive.
     
  • SE_ROWLOCKING_FILTER_OTHER_LOCKS—This is a query filter, affecting SE_stream_fetch_row(), SE_stream_query(), and SE_stream_query_logfile(). Only those features locked by users other than the current user are returned unless other lock filter options are selected; they are additive.
     
  • SE_ROWLOCKING_FILTER_UNLOCKED—This is a query filter, affecting SE_stream_fetch_row(), SE_stream_query(), and SE_stream_query_logfile(). Only those features not locked by any user are returned unless other lock filter options are selected they are additive.
feedback | privacy | legal