com.esri.arcgis.geodatabase
Interface ISchemaLock

All Superinterfaces:
Serializable
All Known Implementing Classes:
CadastralFabric, CodedValueDomain, FeatureClass, FeatureDataset, GeometricNetwork, ISchemaLockProxy, NetworkDataset, ObjectClass, RangeDomain, RasterCatalog, RepresentationClass, SchematicDataset, SchematicDiagram, SchematicDiagramClass, SchematicElementClass, SchematicFolder, SchematicInMemoryFeatureClass, StreetNetwork, Table, Terrain, Topology, UtilityNetwork

public interface ISchemaLock
extends Serializable

Provides access to members for accessing schema locking functionality.

Remarks

The ISchemaLock interface 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.

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.

Product Availability

Available with ArcGIS Engine, ArcGIS Desktop, and ArcGIS Server.


Method Summary
 void changeSchemaLock(int schemaLock)
          Changes a schema lock.
 void getCurrentSchemaLocks(IEnumSchemaLockInfo[] schemaLockInfo)
          The list of current locks.
 

Method Detail

changeSchemaLock

void changeSchemaLock(int schemaLock)
                      throws IOException,
                             AutomationException
Changes a 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.

Product Availability

Available with ArcGIS Engine, ArcGIS Desktop, and ArcGIS Server.

Supported Platforms

Windows, Solaris, Linux

Parameters:
schemaLock - A com.esri.arcgis.geodatabase.esriSchemaLock constant (in)
Throws:
IOException - If there are interop problems.
AutomationException - If the ArcObject component throws an exception.

getCurrentSchemaLocks

void getCurrentSchemaLocks(IEnumSchemaLockInfo[] schemaLockInfo)
                           throws IOException,
                                  AutomationException
The list of current locks.

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.

Product Availability

Available with ArcGIS Engine, ArcGIS Desktop, and ArcGIS Server.

Supported Platforms

Windows, Solaris, Linux

Parameters:
schemaLockInfo - A reference to a com.esri.arcgis.geodatabase.IEnumSchemaLockInfo (out: use single element array)
Throws:
IOException - If there are interop problems.
AutomationException - If the ArcObject component throws an exception.