<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: DA Search Cursor Ignoring sql_clause in ArcGIS Pro Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-questions/da-search-cursor-ignoring-sql-clause/m-p/1718747#M104233</link>
    <description>&lt;P&gt;Thank you for that catch. Yes, I noticed that and corrected, but the problem remained. It turns out, &lt;EM&gt;The input layer was a route event layer, not a gdb feature&lt;/EM&gt; &lt;EM&gt;class&lt;/EM&gt;. The sql_query doesn't work on those, apparently. I exported it as a feature class. It's all good now. Working as it's supposed to.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 05 Aug 2026 17:32:54 GMT</pubDate>
    <dc:creator>RandyMcGregor_BMcD</dc:creator>
    <dc:date>2026-08-05T17:32:54Z</dc:date>
    <item>
      <title>DA Search Cursor Ignoring sql_clause</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/da-search-cursor-ignoring-sql-clause/m-p/1718716#M104226</link>
      <description>&lt;P&gt;A search curser was ignoring the ORDER BY command I had plugged in and I thought I'd enter a nonsense sql_clause just to see what error it threw. The uncommented one below is the cursor command with the nonsense sql_clause&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="RandyMcGregor_BMcD_0-1785945996964.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/156310i27B60872259C3BE4/image-size/medium?v=v2&amp;amp;px=400" role="button" title="RandyMcGregor_BMcD_0-1785945996964.png" alt="RandyMcGregor_BMcD_0-1785945996964.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;It ... runs fine. It doesn't do the ordering I want it to do, of course, but it runs. No error. When I run the line with the ORDER BY clause it completely ignores the order also. The 'order_field' is a field that exists. I've tried hard- coding the field name in the clause. It just won't work.&lt;/P&gt;&lt;P&gt;Throwing this out in the off chance that the problem here is obvious to someone. I suspect I may have to do lots and lots of troubleshooting/error trapping. Something is off here.&lt;/P&gt;&lt;P&gt;Thank you,&lt;/P&gt;&lt;P&gt;Randy McGregor&lt;/P&gt;</description>
      <pubDate>Wed, 05 Aug 2026 16:49:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/da-search-cursor-ignoring-sql-clause/m-p/1718716#M104226</guid>
      <dc:creator>RandyMcGregor_BMcD</dc:creator>
      <dc:date>2026-08-05T16:49:17Z</dc:date>
    </item>
    <item>
      <title>Re: DA Search Cursor Ignoring sql_clause</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/da-search-cursor-ignoring-sql-clause/m-p/1718729#M104229</link>
      <description>&lt;P&gt;Your commented out code is missing a comma (after the fields list) , and it also uses parentheses instead of the list-bracket notation for the SQL clause.&amp;nbsp; Here is a minimum working example, tested both with and without the where_clause:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import arcpy

# URL must point to the specific sublayer index (e.g., /0, /1)
url = "https://sampleserver6.arcgisonline.com/arcgis/rest/services/Wildfire/FeatureServer/2"
layer_name = "Wildfire Polygons"

# Create the feature layer
featureLayer = arcpy.management.MakeFeatureLayer(url, layer_name)

count = 0
print("UNORDERED")
with arcpy.da.SearchCursor(featureLayer, ['objectid', 'symbolID', 'Shape__Area'], where_clause = "symbolID IN (0, 1)") as sCursor:
    for row in sCursor:
        if count &amp;lt; 10:
            # rounded fire boundary area:
            print(  str(round(row[2]) ).rjust(20) )
            count += 1

print("ORDERED:")
count = 0
with arcpy.da.SearchCursor(featureLayer, ['objectid', 'symbolID', 'Shape__Area'], where_clause = "symbolID IN (0, 1)", sql_clause=[None, 'ORDER BY Shape__Area DESC']) as sCursor:
    for row in sCursor:
        if count &amp;lt; 10:
            # rounded fire boundary area:
            print(  str(round(row[2]) ).rjust(20) )
            count += 1&lt;/LI-CODE&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;** EDIT: Just for fun, I traded out the brackets for parentheses, and it still ran!&lt;/P&gt;</description>
      <pubDate>Wed, 05 Aug 2026 16:50:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/da-search-cursor-ignoring-sql-clause/m-p/1718729#M104229</guid>
      <dc:creator>D_Atkins</dc:creator>
      <dc:date>2026-08-05T16:50:36Z</dc:date>
    </item>
    <item>
      <title>Re: DA Search Cursor Ignoring sql_clause</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/da-search-cursor-ignoring-sql-clause/m-p/1718747#M104233</link>
      <description>&lt;P&gt;Thank you for that catch. Yes, I noticed that and corrected, but the problem remained. It turns out, &lt;EM&gt;The input layer was a route event layer, not a gdb feature&lt;/EM&gt; &lt;EM&gt;class&lt;/EM&gt;. The sql_query doesn't work on those, apparently. I exported it as a feature class. It's all good now. Working as it's supposed to.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 05 Aug 2026 17:32:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/da-search-cursor-ignoring-sql-clause/m-p/1718747#M104233</guid>
      <dc:creator>RandyMcGregor_BMcD</dc:creator>
      <dc:date>2026-08-05T17:32:54Z</dc:date>
    </item>
  </channel>
</rss>

