I am having issues with a a WHEREClause....anyone see anything wrong here.
THIS WORKS FINE
inputFeatureclass <SPAN class="operator token">=</SPAN> r<SPAN class="string token">"E:/ArcGISProjects/County/xyz.sde/FeatureClassName"</SPAN>
dataInputParameter2 <SPAN class="operator token">=</SPAN> <SPAN class="string token">"{9A35172E-071F-4A33-B191-172A9B4B02AE}"</SPAN>
whereClause <SPAN class="operator token">=</SPAN> <SPAN class="string token">"FIELDNAME = "</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="string token">"'"</SPAN> <SPAN class="operator token">+</SPAN> dataInputParameter2 <SPAN class="operator token">+</SPAN> <SPAN class="string token">"'"</SPAN>
fields <SPAN class="operator token">=</SPAN> <SPAN class="punctuation token">[</SPAN><SPAN class="string token">'ID'</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">'FIELDNAME'</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">'UNIQUEID'</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">'OBJECTID'</SPAN><SPAN class="punctuation token">]</SPAN>
<SPAN class="keyword token">with</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>da<SPAN class="punctuation token">.</SPAN>SearchCursor<SPAN class="punctuation token">(</SPAN>inputFeatureclass<SPAN class="punctuation token">,</SPAN> fields<SPAN class="punctuation token">,</SPAN> whereClause<SPAN class="punctuation token">)</SPAN> <SPAN class="keyword token">as</SPAN> cursor<SPAN class="punctuation token">:</SPAN>
<SPAN class="keyword token">for</SPAN> row <SPAN class="keyword token">in</SPAN> cursor<SPAN class="punctuation token">:</SPAN>
<SPAN class="keyword token">print</SPAN> <SPAN class="string token">"--QUERY RESULT FROM MAIN FEATURE SERVICE ------"</SPAN>
<SPAN class="keyword token">print</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="string token">'{0}, {1}, {2}, {3}'</SPAN><SPAN class="punctuation token">.</SPAN>format<SPAN class="punctuation token">(</SPAN>row<SPAN class="punctuation token">[</SPAN><SPAN class="number token">0</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">,</SPAN> row<SPAN class="punctuation token">[</SPAN><SPAN class="number token">1</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">,</SPAN> row<SPAN class="punctuation token">[</SPAN><SPAN class="number token">2</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">,</SPAN> row<SPAN class="punctuation token">[</SPAN><SPAN class="number token">3</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="keyword token">print</SPAN> <SPAN class="string token">""</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>BUT NOW TRYING TO USE -- SelectByAttrbute
inputFeatureclass <SPAN class="operator token">=</SPAN> r<SPAN class="string token">"E:/ArcGISProjects/County/xyz.sde/FeatureClassName"</SPAN>
dataInputParameter2 <SPAN class="operator token">=</SPAN> <SPAN class="string token">"{9A35172E-071F-4A33-B191-172A9B4B02AE}"</SPAN>
whereClause <SPAN class="operator token">=</SPAN> <SPAN class="string token">"FIELDNAME = "</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="string token">"'"</SPAN> <SPAN class="operator token">+</SPAN> dataInputParameter2 <SPAN class="operator token">+</SPAN> <SPAN class="string token">"'"</SPAN>
results2 <SPAN class="operator token">=</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>SelectLayerByAttribute_management<SPAN class="punctuation token">(</SPAN>inputFeatureclass<SPAN class="punctuation token">,</SPAN> <SPAN class="string token">'NEW_SELECTION'</SPAN><SPAN class="punctuation token">,</SPAN> whereClause<SPAN class="punctuation token">)</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>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).