Provides access to members for accessing schema locking functionality.
When To Use
Use ISchemaLock to establish an exclusive lock on a dataset when changing its schema, or performing other operations that require exclusive access to the data.
Members
Name | Description | |
---|---|---|
ChangeSchemaLock | Changes a schema lock. | |
GetCurrentSchemaLocks | The list of current locks. |
ISchemaLock.ChangeSchemaLock Method
Changes a schema lock.
Public Sub ChangeSchemaLock ( _
ByVal schemaLock As esriSchemaLock _
)
public void ChangeSchemaLock (
esriSchemaLock schemaLock
);
Errors Returned
FDO_E_MUST_BE_OWNER: Returned when a user other than the owner of a dataset tries to acquire an exclusive schema lock.
Remarks
There are two kinds of schema locks: shared and exclusive. Shared schema locks are applied automatically by the geodatabase when accessing a dataset and are removed when all references to the dataset are removed. For this reason, it's not necessary to explicitly apply or remove shared schema locks. There is no limit to the number of shared schema locks a dataset or object can have at any given time.
In contrast to shared schema locks, exclusive schema locks are controlled by the developer or ArcGIS application, such as ArcMap or ArcCatalog. An exclusive lock is used to lock a geodatabase dataset or object from use by others to make the necessary changes to it. An exclusive lock is promoted from a shared lock and demoted back to a shared lock when no longer needed. The presence of additional shared schema locks on a dataset or object prevents an exclusive schema lock from being applied and precludes the ability to make changes to the underlying dataset and its schema while it is in use. Only one exclusive schema lock is allowed per dataset. As opposed to shared schema locks, exclusive schema locks are not applied or removed automatically; it is the responsibility of the developer to apply or remove exclusive schema locks.
Limit the scope of exclusive schema locks to the operation that requires the lock. Gather the necessary information to perform the action, obtain the exclusive lock, make the change, and release the lock. Some examples of operations for which an exclusive schema lock should be obtained include:
- Modifications to attribute domains, such as adding or removing values from a coded value domain or changing the range for range domains
- Adding or deleting a field from a feature class or object class
- Associating a class extension with a feature class
- Creating a topology, geometric network, network dataset, terrain, schematic dataset, representation, or cadastral fabric on a set of feature classes
- Any use of the IClassSchemaEdit interface
- Putting a feature class into and taking it out of load-only mode with the IFeatureClassLoad.LoadOnlyMode method
- Managing (creating, deleting, or modifying) spatial and attribute indexes
Once the action requiring an exclusive schema lock is complete, the exclusive schema lock must be demoted to a shared lock. This includes when errors are raised during the schema modification, for example, consider the case where a field is being deleted from a feature class. To delete the field, an exclusive schema lock is obtained. However, on the call to DeleteField, an error is thrown; that is, the field being deleted is a required field, such as the ObjectID field. In the handling of the error, the exclusive schema lock must be demoted to a shared lock before proceeding.
ISchemaLock.GetCurrentSchemaLocks Method
The list of current locks.
Public Sub GetCurrentSchemaLocks ( _
ByRef schemaLockInfo As IEnumSchemaLockInfo _
)
public void GetCurrentSchemaLocks (
ref IEnumSchemaLockInfo schemaLockInfo
);
Remarks
The ISchemaLockInfo interface is used in concert with ISchemaLock to provide information about a schema lock, for example, whether it is shared or exclusive and for ArcSDE geodatabases, the name of the user who has the lock. Note that there will always be at least one schema lock on the dataset. Also note that by checking the schema locks on a dataset a shared schema lock is applied to the data.
Classes that implement ISchemaLock
Classes | Description |
---|---|
CodedValueDomain | Esri Attribute set constraint object. |
FeatureClass | Esri Feature Class object. |
ObjectClass | Esri Object Class object. |
RangeDomain | Esri Range Domain object. |
RasterCatalog | A collection of raster datasets in a Geodatabase table. |
Table | Esri Table object. |
Remarks
The ISchemaLockinterface can be used to establish a shared lock on data. When accessing data using the ArcGIS application, shared locks are applied automatically. Exclusive locks are never applied automatically, and when performing an action that requires an exclusive hold on the data, you must apply an exclusive lock.
Examples of operations that should acquire a schema lock include adding a field to a feature class, associating a new class extension with a feature class, or building a geometric network on a set of feature classes.
When obtaining an exclusive schema lock on a personal geodatabase; any open row sets from the specific personal geodatabase will be invalidated; such as a cursor populated through the IFeatureClass.Search method. For this reason; the exclusive schema lock should be obtained prior to populating a row set; such as cursors.