I get this error when 'arcpy.SelectLayerByAttribute_management' statement is executed. I tried many different ways to format my whereclause. I had printed it and it looks fine. But the error still there.
Anyone had similar problem?
fc_layer is a feature layer, that created in the code from a feature class in file geodatabase.
Runtime error Traceback (most recent call last): File "", line 6, in File "c:\program files (x86)\arcgis\desktop10.3\arcpy\arcpy\management.py", line 7221, in SelectLayerByAttribute raise e ExecuteError: ERROR 000358: Invalid expression Failed to execute (SelectLayerByAttribute).
My code:
field1 = ['OBJECTID']
with arcpy.da.UpdateCursor('fc_layer', field1) as cursor:
for row in cursor:
currentID = row[0]
whereClause1 = ''' "OBJECTID" = {0} '''.format(currentID)
arcpy.SelectLayerByAttribute_management("fc_layer", "NEW_SELECTION", whereClause1)
arcpy.SelectLayerByLocation_management("fc_layer", "BOUNDARY_TOUCHES", "fc_layer", "","ADD_TO_SELECTION", "NOT_INVERT")