<?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: Do SQL statements in arcpy DA Searchcursors accept shape tokens? in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/do-sql-statements-in-arcpy-da-searchcursors-accept/m-p/1111769#M62823</link>
    <description>&lt;P&gt;Here's the code I'm currently using BTW. Autoincrement is just the sample from Esri docs:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import arcpy
from AutoIncrement import AutoIncrement

def SpatialRenumberPoints(InLayer):
    arcpy.management.AddXY(InLayer)
    arcpy.AddField_management(InLayer, "NewID", 'LONG')
    fields = ['OID@','POINT_X','POINT_Y','NewID']
    sqlOrder = "ORDER BY {0} DESC, {1} ASC".format(fields[2], fields[1])
    with arcpy.da.UpdateCursor(InLayer, fields,sql_clause = (None, sqlOrder)) as cursor:
        for row in cursor:
            row[3] = AutoIncrement()
            cursor.updateRow(row)&lt;/LI-CODE&gt;</description>
    <pubDate>Wed, 27 Oct 2021 17:49:27 GMT</pubDate>
    <dc:creator>ZacharyHart</dc:creator>
    <dc:date>2021-10-27T17:49:27Z</dc:date>
    <item>
      <title>Do SQL statements in arcpy DA Searchcursors accept shape tokens?</title>
      <link>https://community.esri.com/t5/python-questions/do-sql-statements-in-arcpy-da-searchcursors-accept/m-p/1111679#M62822</link>
      <description>&lt;P&gt;I'm trying to create a simple function to sort based on a point FC X &amp;amp; Y values and then add a sequential ID. I know the 'old' update cursor supports sort fields directly, where arcpy.da.searchcursor you must use an SQL statement such as ORDER BY.&lt;/P&gt;&lt;P&gt;I'm leaning towards using shape tokens since the input FC may or may not have an X &amp;amp; Y coordinate field.&lt;/P&gt;&lt;LI-CODE lang="python"&gt;fields = ['OID@','SHAPE@X','SHAPE@Y','NewID']
sqlOrder = "ORDER BY {0}, {1} ASC".format(fields[1],fields[2])
startNumber = 100
 with arcpy.da.UpdateCursor('Renum', fields,sql_clause = (None, sqlOrder) as cusor:
   for row in cursor:
       row[3] = startNumber + 1
       cursor.updateRow(row)&lt;/LI-CODE&gt;&lt;P&gt;For which I'm getting:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;Traceback (most recent call last):
  File "&amp;lt;string&amp;gt;", line 2, in &amp;lt;module&amp;gt;
RuntimeError: Bad syntax in request. (status code 400).&lt;/LI-CODE&gt;&lt;P&gt;The input FC is in a fGDB so SQL ORDER BY is supported (according to the documentation).&lt;/P&gt;&lt;P&gt;I guess this is less so about evaluating this code as it is the question: do SQL statements accepts shape tokens?&lt;/P&gt;&lt;P&gt;I guess my alternative is to simply add XY values and then have a known set of fields to work with.&lt;/P&gt;</description>
      <pubDate>Wed, 27 Oct 2021 15:29:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/do-sql-statements-in-arcpy-da-searchcursors-accept/m-p/1111679#M62822</guid>
      <dc:creator>ZacharyHart</dc:creator>
      <dc:date>2021-10-27T15:29:55Z</dc:date>
    </item>
    <item>
      <title>Re: Do SQL statements in arcpy DA Searchcursors accept shape tokens?</title>
      <link>https://community.esri.com/t5/python-questions/do-sql-statements-in-arcpy-da-searchcursors-accept/m-p/1111769#M62823</link>
      <description>&lt;P&gt;Here's the code I'm currently using BTW. Autoincrement is just the sample from Esri docs:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import arcpy
from AutoIncrement import AutoIncrement

def SpatialRenumberPoints(InLayer):
    arcpy.management.AddXY(InLayer)
    arcpy.AddField_management(InLayer, "NewID", 'LONG')
    fields = ['OID@','POINT_X','POINT_Y','NewID']
    sqlOrder = "ORDER BY {0} DESC, {1} ASC".format(fields[2], fields[1])
    with arcpy.da.UpdateCursor(InLayer, fields,sql_clause = (None, sqlOrder)) as cursor:
        for row in cursor:
            row[3] = AutoIncrement()
            cursor.updateRow(row)&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 27 Oct 2021 17:49:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/do-sql-statements-in-arcpy-da-searchcursors-accept/m-p/1111769#M62823</guid>
      <dc:creator>ZacharyHart</dc:creator>
      <dc:date>2021-10-27T17:49:27Z</dc:date>
    </item>
    <item>
      <title>Re: Do SQL statements in arcpy DA Searchcursors accept shape tokens?</title>
      <link>https://community.esri.com/t5/python-questions/do-sql-statements-in-arcpy-da-searchcursors-accept/m-p/1111863#M62826</link>
      <description>&lt;P&gt;&lt;A href="https://pro.arcgis.com/en/pro-app/latest/arcpy/data-access/searchcursor-class.htm" target="_blank"&gt;SearchCursor—ArcGIS Pro | Documentation&lt;/A&gt;&lt;/P&gt;&lt;P&gt;see example 5A and 5B if ordering/sorting is the issue, there is python alternative to sql&lt;/P&gt;</description>
      <pubDate>Wed, 27 Oct 2021 20:38:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/do-sql-statements-in-arcpy-da-searchcursors-accept/m-p/1111863#M62826</guid>
      <dc:creator>DanPatterson</dc:creator>
      <dc:date>2021-10-27T20:38:40Z</dc:date>
    </item>
    <item>
      <title>Re: Do SQL statements in arcpy DA Searchcursors accept shape tokens?</title>
      <link>https://community.esri.com/t5/python-questions/do-sql-statements-in-arcpy-da-searchcursors-accept/m-p/1112120#M62830</link>
      <description>&lt;P&gt;A shape token is an Esri construct that backend datastores (shapefile, file geodatabase, enterprise geodatabase, etc...) don't know exist, so passing "SHAPE@X" in a SQL WHERE clause will fail regardless of the backend datastore.&lt;/P&gt;&lt;P&gt;In general, the SQL clauses with ArcPy DA cursors are passed straight through to the backend datastore, so what you can do in the SQL clauses varies.&amp;nbsp; For shapefiles and file geodatabases, I don't believe any spatial methods are supported in SQL clauses; however, you can use spatial methods in SQL clauses with enterprise geodatabases.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 28 Oct 2021 14:49:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/do-sql-statements-in-arcpy-da-searchcursors-accept/m-p/1112120#M62830</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2021-10-28T14:49:18Z</dc:date>
    </item>
  </channel>
</rss>

