<?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: SQL sort parameter syntax for da.cursors? in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/sql-sort-parameter-syntax-for-da-cursors/m-p/652072#M50788</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;I logged a new bug for this issue, NIM083765.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Appreciate that. Thanks Chris.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 13 Aug 2012 23:30:09 GMT</pubDate>
    <dc:creator>ChrisSnyder</dc:creator>
    <dc:date>2012-08-13T23:30:09Z</dc:date>
    <item>
      <title>SQL sort parameter syntax for da.cursors?</title>
      <link>https://community.esri.com/t5/python-questions/sql-sort-parameter-syntax-for-da-cursors/m-p/652064#M50780</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Looking for examples of using the "ORDER_BY" SQL syntax that is now suported in the arcpy.da cursor model...&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Help system is lacking in examples on this front...&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Can any v10.1 pro rewrite this in arcpy.da format?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;arcpy.UpdateCursor(oesfHydroDislvFC, "", "", "", "SL_WTRTY_CD A;RIP_COMBO_UID D")&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 13 Aug 2012 20:03:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/sql-sort-parameter-syntax-for-da-cursors/m-p/652064#M50780</guid>
      <dc:creator>ChrisSnyder</dc:creator>
      <dc:date>2012-08-13T20:03:33Z</dc:date>
    </item>
    <item>
      <title>Re: SQL sort parameter syntax for da.cursors?</title>
      <link>https://community.esri.com/t5/python-questions/sql-sort-parameter-syntax-for-da-cursors/m-p/652065#M50781</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;it would be something like:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
sqlClause = (None, "ORDER BY Field1 ASC, Field2 DESC")
arcpy.da.UpdateCursor(inFC, fields, sql_clause=sqlClause)
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Make sure any fields you use in the sql expression are also passed in the field_names parameter.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 03:38:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/sql-sort-parameter-syntax-for-da-cursors/m-p/652065#M50781</guid>
      <dc:creator>ChrisFox3</dc:creator>
      <dc:date>2021-12-12T03:38:52Z</dc:date>
    </item>
    <item>
      <title>Re: SQL sort parameter syntax for da.cursors?</title>
      <link>https://community.esri.com/t5/python-questions/sql-sort-parameter-syntax-for-da-cursors/m-p/652066#M50782</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks Chris&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm thinking the "fancy" SQL parameter is the 6th one down the line, so it probably should be something like this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.da.UpdateCursor(oesfHydroDislvFC, fieldList, None, None, False, (None, 'ORDER_BY SL_WTRTY_CD, RIP_COMBO_UID DESC'))&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;But that is thowing an error:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Traceback (most recent call last):&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; File "&amp;lt;interactive input&amp;gt;", line 1, in &amp;lt;module&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;TypeError: expected callable function - logger(obj)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Been trying a lot of things for a while - with nothing working out...&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 13 Aug 2012 20:29:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/sql-sort-parameter-syntax-for-da-cursors/m-p/652066#M50782</guid>
      <dc:creator>ChrisSnyder</dc:creator>
      <dc:date>2012-08-13T20:29:37Z</dc:date>
    </item>
    <item>
      <title>Re: SQL sort parameter syntax for da.cursors?</title>
      <link>https://community.esri.com/t5/python-questions/sql-sort-parameter-syntax-for-da-cursors/m-p/652067#M50783</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;A related thread: &lt;/SPAN&gt;&lt;A href="http://forums.arcgis.com/threads/49897-arcpy.da.Searchcursor-sql_clause"&gt;http://forums.arcgis.com/threads/49897-arcpy.da.Searchcursor-sql_clause&lt;/A&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 13 Aug 2012 20:39:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/sql-sort-parameter-syntax-for-da-cursors/m-p/652067#M50783</guid>
      <dc:creator>ChrisSnyder</dc:creator>
      <dc:date>2012-08-13T20:39:29Z</dc:date>
    </item>
    <item>
      <title>Re: SQL sort parameter syntax for da.cursors?</title>
      <link>https://community.esri.com/t5/python-questions/sql-sort-parameter-syntax-for-da-cursors/m-p/652068#M50784</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Thanks Chris&lt;BR /&gt;&lt;BR /&gt;I'm thinking the "fancy" SQL parameter is the 6th one down the line, so it probably should be something like this:&lt;BR /&gt;&lt;BR /&gt;arcpy.da.UpdateCursor(oesfHydroDislvFC, fieldList, None, None, False, (None, 'ORDER_BY SL_WTRTY_CD, RIP_COMBO_UID DESC'))&lt;BR /&gt;&lt;BR /&gt;But that is thowing an error:&lt;BR /&gt;Traceback (most recent call last):&lt;BR /&gt;&amp;nbsp; File "&amp;lt;interactive input&amp;gt;", line 1, in &amp;lt;module&amp;gt;&lt;BR /&gt;TypeError: expected callable function - logger(obj)&lt;BR /&gt;&lt;BR /&gt;Been trying a lot of things for a while - with nothing working out...&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If you used a named parameter than you don't have to specify the value for every optional paramater to the function. This makes your code a lot easier to write and read and sometimes resolves errors that may have accidentally been added. So since you are just accepting the defaults for the 3rd 4th and 5th parameter you could change your code to:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;arcpy.da.UpdateCursor(oesfHydroDislvFC, fieldList, sql_clause=(None, 'ORDER_BY SL_WTRTY_CD, RIP_COMBO_UID DESC'))&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Also make sure the input is a Geodatasbase Feature Class, the sql_clause paramater does not work on shapefiles. I just tested this similar expression on my data and it worked as expected. If you remove the sql_clause paramater is the cursor created succesfully? Did you want to share a small subset of your data?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 13 Aug 2012 20:48:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/sql-sort-parameter-syntax-for-da-cursors/m-p/652068#M50784</guid>
      <dc:creator>ChrisFox3</dc:creator>
      <dc:date>2012-08-13T20:48:18Z</dc:date>
    </item>
    <item>
      <title>Re: SQL sort parameter syntax for da.cursors?</title>
      <link>https://community.esri.com/t5/python-questions/sql-sort-parameter-syntax-for-da-cursors/m-p/652069#M50785</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Additional info, I get the same error as you if I attempt to enter all the parameters in the same order as specified in the function's signature.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&amp;gt;&amp;gt;&amp;gt; rows = arcpy.da.UpdateCursor("U.S. Cities", fields, None, None, False, (None, 'Order By STATE_NAME, TYPE DESC'))
Runtime error 
Traceback (most recent call last):
&amp;nbsp; File "&amp;lt;string&amp;gt;", line 1, in &amp;lt;module&amp;gt;
TypeError: expected callable function - logger(obj)&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This seems to be a bug, I will look into this further. Using sql_clause= instead works.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&amp;gt;&amp;gt;&amp;gt; rows = arcpy.da.UpdateCursor("U.S. Cities", fields, None, None, False, sql_clause=(None, 'Order By STATE_NAME, TYPE DESC'))&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 03:38:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/sql-sort-parameter-syntax-for-da-cursors/m-p/652069#M50785</guid>
      <dc:creator>ChrisFox3</dc:creator>
      <dc:date>2021-12-12T03:38:54Z</dc:date>
    </item>
    <item>
      <title>Re: SQL sort parameter syntax for da.cursors?</title>
      <link>https://community.esri.com/t5/python-questions/sql-sort-parameter-syntax-for-da-cursors/m-p/652070#M50786</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Okay - I get the 'named parameter' thing... .It's working now... Thanks Chris and Jason!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Correct sytax for a multiple field sort:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.da.UpdateCursor(oesfHydroDislvFC, fieldList, sql_clause=(None, 'ORDER BY SL_WTRTY_CD, RIP_COMBO_UID DESC'))&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Note that the Help system indicates "ORDER_BY" but it is really "ORDER BY" (with no underscore).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;VERIFIED:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.da.UpdateCursor(oesfHydroDislvFC, fieldList, None, None, False, (None,'ORDER BY SL_WTRTY_CD, RIP_COMBO_UID DESC'))&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;results in an error.... Not sure why...&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 13 Aug 2012 21:04:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/sql-sort-parameter-syntax-for-da-cursors/m-p/652070#M50786</guid>
      <dc:creator>ChrisSnyder</dc:creator>
      <dc:date>2012-08-13T21:04:55Z</dc:date>
    </item>
    <item>
      <title>Re: SQL sort parameter syntax for da.cursors?</title>
      <link>https://community.esri.com/t5/python-questions/sql-sort-parameter-syntax-for-da-cursors/m-p/652071#M50787</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I logged a new bug for this issue, NIM083765.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 13 Aug 2012 21:57:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/sql-sort-parameter-syntax-for-da-cursors/m-p/652071#M50787</guid>
      <dc:creator>ChrisFox3</dc:creator>
      <dc:date>2012-08-13T21:57:38Z</dc:date>
    </item>
    <item>
      <title>Re: SQL sort parameter syntax for da.cursors?</title>
      <link>https://community.esri.com/t5/python-questions/sql-sort-parameter-syntax-for-da-cursors/m-p/652072#M50788</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;I logged a new bug for this issue, NIM083765.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Appreciate that. Thanks Chris.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 13 Aug 2012 23:30:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/sql-sort-parameter-syntax-for-da-cursors/m-p/652072#M50788</guid>
      <dc:creator>ChrisSnyder</dc:creator>
      <dc:date>2012-08-13T23:30:09Z</dc:date>
    </item>
    <item>
      <title>Re: SQL sort parameter syntax for da.cursors?</title>
      <link>https://community.esri.com/t5/python-questions/sql-sort-parameter-syntax-for-da-cursors/m-p/652073#M50789</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;give a look at this&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://forums.arcgis.com/threads/930...656#post330656"&gt;http://forums.arcgis.com/threads/930...656#post330656&lt;/A&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 26 Sep 2013 15:49:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/sql-sort-parameter-syntax-for-da-cursors/m-p/652073#M50789</guid>
      <dc:creator>oscarespitia</dc:creator>
      <dc:date>2013-09-26T15:49:40Z</dc:date>
    </item>
  </channel>
</rss>

