AnsweredAssumed Answered

SelctByAttribute not working

Question asked by jay.kapalczynski on May 12, 2020
Latest reply on May 12, 2020 by jay.kapalczynski

I am having issues with a a WHEREClause....anyone see anything wrong here.

 

THIS WORKS FINE

inputFeatureclass = r"E:/ArcGISProjects/County/xxx.sde/FeatureClassName"
dataInputParameter2 = "{9A35172E-071F-4A33-B191-172A9B4B02AE}"
whereClause = "FIELDNAME = " + "'" + dataInputParameter2 + "'"
fields = ['ID', 'FIELDNAME', 'UNIQUEID', 'OBJECTID']

with arcpy.da.SearchCursor(inputFeatureclass, fields, whereClause) as cursor:
    for row in cursor:
        print "--QUERY RESULT FROM MAIN FEATURE SERVICE ------"
        print('{0}, {1}, {2}, {3}'.format(row[0], row[1], row[2], row[3]))
        print ""

 

BUT NOW TRYING TO USE -- SelectByAttrbute

 

inputFeatureclass = r"E:/ArcGISProjects/County/xxx.sde/FeatureClassName"
dataInputParameter2 = "{9A35172E-071F-4A33-B191-172A9B4B02AE}"
whereClause = "FIELDNAME = " + "'" + dataInputParameter2 + "'"

results2 = arcpy.SelectLayerByAttribute_management(inputFeatureclass, 'NEW_SELECTION', whereClause)

 

Now I get this error when trying SelectByAttrbute

 

NOTE:  This is a GUID field data type in SDE SQL Server db

 

Traceback (most recent call last):
File "E:\ArcGISProjects\County\Python\UpdateGeometryJSON.py", line 94, in <module>
results2 = arcpy.SelectLayerByAttribute_management(inputFeatureclass, 'NEW_SELECTION', whereClause)
File "C:\Program Files (x86)\ArcGIS\Desktop10.5\ArcPy\arcpy\management.py", line 7744, in SelectLayerByAttribute
raise e
ExecuteError: Failed to execute. Parameters are not valid.
The value cannot be a feature class
ERROR 000840: The value is not a Raster Layer.
ERROR 000840: The value is not a Mosaic Layer.
Failed to execute (SelectLayerByAttribute).

Outcomes