TestSchemaLock
サマリ
Tests if a schema lock can be acquired for a feature class, table, or feature dataset. Tools that alter schema will require a schema lock to be placed on the input data. The Add Field tool is an example of such a tool. If the tool requires a schema lock and is unable to aquire one at the time of execution, an appropriate error message is returned. Scripts that use such tools should test if a schema lock can be acquired on the input data. The TestSchemaLock function will not actually apply a schema lock on the input data, but will return a Boolean.
構文
パラメータ | 説明 | データ タイプ |
dataset |
The input data to be tested if a schema lock can be applied. | String |
データ タイプ | 説明 |
Boolean |
Returns a Boolean indicating if a schema lock can be applied to the input dataset. The possible Boolean values are:
|
コードのサンプル
Returns a Boolean True if exclusive lock can be applied to dataset.
import arcpy # Get the value of the input argument. # The argument should be a feature class. # data = arcpy.GetParameterAsText(0) # Test if a schema lock can be applied. # lockTest = arcpy.TestSchemaLock(data) # If the lock can be applied, add a new field. # if lockTest: arcpy.AddField_management(data,"Flag","long") else: print "Unable to acquire the necessary schema lock to add the new field"