AddFieldDelimiters

Zusammenfassung

Adds field delimiters to a field name to allow for use in SQL expressions.

Syntax

AddFieldDelimiters (datasource, field)
ParameterErläuterungDatentyp
datasource

The field delimiters are based on the data source used.

String
field

The field name to which delimiters will be added. The field does not have to currently exist.

String
Rückgabewert
DatentypErläuterung
String

Returns a delimited field name.

Codebeispiel

AddFieldDelimiters example
import arcpy
from arcpy import env

fieldName      = arcpy.GetParameterAsText(0)
wkspace        = arcpy.GetParameterAsText(1)
in_features    = arcpy.GetParameterAsText(2)
out_feat_class = arcpy.GetParameterAsText(3)
stateVal       = arcpy.GetParameterAstext(4)

# AddFieldDelimiters will return a field name with the proper
#  field delimiters for the workspace specified.
#
newName = arcpy.AddFieldDelimiters("C:/Data", fieldName)

# Use delimited field for Select tool SQL expression
#
sqlExp = newName + " = " + stateVal
env.workspace = wkspace
arcpy.Select_analysis(in_features, out_feat_class, sqlExp)   

Verwandte Themen


7/10/2012