Difference between AddFieldDelimiters and ValidateFieldName

Discussion created by musian1 on Dec 7, 2010
Latest reply on Apr 16, 2012 by sbarrow
For the script as below, can I directly use fieldname, rather than newName in SQL? (so delete newName = arcpy.AddFieldDelimiters("C:/Data", fieldName) ...)

If not, why? When to use AddFieldDelimiters? Any difference to ValidateFieldName? Thanks indeed!!

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)

# AddFieldDelimieters will return a field name will 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)