<?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: arcpy.da.Searchcursor sql_clause in Geoprocessing Questions</title>
    <link>https://community.esri.com/t5/geoprocessing-questions/arcpy-da-searchcursor-sql-clause/m-p/215395#M7383</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/93056-manual-selection-as-input-parameter-for-a-script?p=330656#post330656"&gt;http://forums.arcgis.com/threads/93056-manual-selection-as-input-parameter-for-a-script?p=330656#post330656&lt;/A&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 26 Sep 2013 15:49:06 GMT</pubDate>
    <dc:creator>oscarespitia</dc:creator>
    <dc:date>2013-09-26T15:49:06Z</dc:date>
    <item>
      <title>arcpy.da.Searchcursor sql_clause</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/arcpy-da-searchcursor-sql-clause/m-p/215385#M7373</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Can someone shed a bit of light on the sql_clause parameter on arcpy.da.SearchCursor?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The help states that the pre-fix supports None, DISTINCT and TOP and the post-fix supports None, ORDER_BY and GROUP_BY, but I'm not sure how to formulate it corrcetly.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;For example:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;layer = "c:/temp/myGdb.gdb/myFeatureClass"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;dsc = arcpy.Describe(layer)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;OIDFieldName = dsc.OIDFieldName&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;delimitedFieldName = arcpy.AddFieldDelimiters(layer, OIDFieldName)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;sWhereClause = delimitedFieldName + " &amp;lt; 100"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;sql_clause = (None,'ORDER BY OBJECTID DESC')&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;rows = arcpy.da.SearchCursor(layer,("SHAPE@","OID@"),sWhereClause,None,False,sql_clause)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;rows.reset()&amp;nbsp; # Throws a 'not callable function' error&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Feb 2012 13:38:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/arcpy-da-searchcursor-sql-clause/m-p/215385#M7373</guid>
      <dc:creator>MarcHoogerwerf</dc:creator>
      <dc:date>2012-02-12T13:38:33Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy.da.Searchcursor sql_clause</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/arcpy-da-searchcursor-sql-clause/m-p/215386#M7374</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;You don't need to call reset(), you should be able to just do&lt;/SPAN&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_macro_code jive_text_macro"&gt; for row in arcpy.da.SearchCursor(layer,("SHAPE@","OID@"),sWhereClause,None,False,sql_clause):&lt;/PRE&gt;&lt;SPAN&gt; and avoid all that extra code.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Feb 2012 16:41:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/arcpy-da-searchcursor-sql-clause/m-p/215386#M7374</guid>
      <dc:creator>JasonScheirer</dc:creator>
      <dc:date>2012-02-12T16:41:26Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy.da.Searchcursor sql_clause</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/arcpy-da-searchcursor-sql-clause/m-p/215387#M7375</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Can tokens such as "SHAPE@X" be used in the sql_clause or the&amp;nbsp; where clause? &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Whenever I try and use an sql clause with one of these it says it cannot find the field.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Feb 2012 21:23:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/arcpy-da-searchcursor-sql-clause/m-p/215387#M7375</guid>
      <dc:creator>GusMartinka</dc:creator>
      <dc:date>2012-02-15T21:23:22Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy.da.Searchcursor sql_clause</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/arcpy-da-searchcursor-sql-clause/m-p/215388#M7376</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;No, the special tokens can only be used in the list of columns you'd like to select.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 20 Feb 2012 19:10:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/arcpy-da-searchcursor-sql-clause/m-p/215388#M7376</guid>
      <dc:creator>JasonScheirer</dc:creator>
      <dc:date>2012-02-20T19:10:22Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy.da.Searchcursor sql_clause</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/arcpy-da-searchcursor-sql-clause/m-p/215389#M7377</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;You don't need to call reset(), you should be able to just do&lt;PRE class="lia-code-sample line-numbers language-none"&gt; for row in arcpy.da.SearchCursor(layer,("SHAPE@","OID@"),sWhereClause,None,False,sql_clause):&lt;/PRE&gt; and avoid all that extra code.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I tried this one&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; dsc = arcpy.Describe("Demo.DBO.U1H000Ruimte")
&amp;gt;&amp;gt;&amp;gt; OIDFieldName = dsc.OIDFieldName
&amp;gt;&amp;gt;&amp;gt; delimitedFieldName = arcpy.AddFieldDelimiters("Demo.DBO.U1H000Ruimte", OIDFieldName)
&amp;gt;&amp;gt;&amp;gt; print delimitedFieldName
"OBJECTID"
&amp;gt;&amp;gt;&amp;gt; sWhereClause = delimitedFieldName + " &amp;lt; 100"
&amp;gt;&amp;gt;&amp;gt; print sWhereClause
"OBJECTID" &amp;lt; 100
&amp;gt;&amp;gt;&amp;gt; sql_clause = (None,'ORDER BY OBJECTID DESC')
&amp;gt;&amp;gt;&amp;gt; print sql_clause
(None, 'ORDER BY OBJECTID DESC')

&amp;gt;&amp;gt;&amp;gt; for row in arcpy.da.SearchCursor("Demo.DBO.U1H000Ruimte",("SHAPE@","OID@"),sWhereClause,None,False,sql_clause):
...&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print row[1]
...&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
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;Then tried:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;sql_clause = (None,'ORDER BY "OBJECTID" DESC')&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;But I keep getting the same results.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Everything is ok if I omit the sql_clause part, so I must doing something wrong with that part. Any ideas?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Update: Then tried this one, swapping the explode_to_points and sql_clause parameters&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
&amp;gt;&amp;gt;&amp;gt; for row in arcpy.da.SearchCursor("Demo.DBO.U1H000Ruimte",("SHAPE@","OID@"),sWhereClause,None,(None,'order by objectid desc'),None):
...&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print row[1]
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This will print the objectids but not in descending order. What I don't understand is that the tuple is accepted for the explode_to_points parameter (that is supposed to take values of True and False only)&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 10:33:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/arcpy-da-searchcursor-sql-clause/m-p/215389#M7377</guid>
      <dc:creator>MarcHoogerwerf</dc:creator>
      <dc:date>2021-12-11T10:33:22Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy.da.Searchcursor sql_clause</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/arcpy-da-searchcursor-sql-clause/m-p/215390#M7378</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;arcpy.da is a Defense Analyst module?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Is there a reason to use a Search Cursor in arcpy.da instad of the one in arcpy?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The standard arcpy Search Cursor sort fields syntax is "FIELD_1 A; FIELD_2 D"&amp;nbsp; to sort the first assending and the second decending.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Of course, in a different module the syntax could very well be very different.... after all, let's remember who wrote these modules.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 22 May 2012 11:26:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/arcpy-da-searchcursor-sql-clause/m-p/215390#M7378</guid>
      <dc:creator>markdenil</dc:creator>
      <dc:date>2012-05-22T11:26:13Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy.da.Searchcursor sql_clause</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/arcpy-da-searchcursor-sql-clause/m-p/215391#M7379</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;arcpy.da is a Defense Analyst module?&lt;BR /&gt;&lt;BR /&gt;Is there a reason to use a Search Cursor in arcpy.da instad of the one in arcpy?&lt;BR /&gt;&lt;BR /&gt;The standard arcpy Search Cursor sort fields syntax is "FIELD_1 A; FIELD_2 D"&amp;nbsp; to sort the first assending and the second decending.&lt;BR /&gt;Of course, in a different module the syntax could very well be very different.... after all, let's remember who wrote these modules.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Nope arcpy.da.SearchCursor is a 10.1 Data Access SearchCursor and it uses a slightly different syntax. Best reason to use the da.SearchCursor instead of the old SearchCursor is speed and fexibility. The sql_clause is documented in the online help system, so it should work, but I'm probably missing something.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 22 May 2012 11:40:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/arcpy-da-searchcursor-sql-clause/m-p/215391#M7379</guid>
      <dc:creator>MarcHoogerwerf</dc:creator>
      <dc:date>2012-05-22T11:40:32Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy.da.Searchcursor sql_clause</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/arcpy-da-searchcursor-sql-clause/m-p/215392#M7380</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi Marc (Hoogerwerf) - Did you ever get the SQL sort function to work?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm having the same difficulty...&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Trying to make this old code:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;arcpy.UpdateCursor(oesfHydroDislvFC, "", "", "", "SL_WTRTY_CD A;RIP_COMBO_UID D")&lt;/PRE&gt;&lt;SPAN&gt;Fly in v10.1...&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Trying all sorts of derivations of:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;fieldList = ["SL_WTRTY_CD","RIP_COMBO_UID","CHAN_WIDTH"]
updateRows = arcpy.da.UpdateCursor(oesfHydroDislvFC, fieldList, None, None, False, (None, 'ORDER BY SL_WTRTY_CD, RIP_COMBO_UID DESC'))&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;but no luck so far...&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Common error is:&lt;/SPAN&gt;&lt;BR /&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;Any suggestions?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 10:33:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/arcpy-da-searchcursor-sql-clause/m-p/215392#M7380</guid>
      <dc:creator>ChrisSnyder</dc:creator>
      <dc:date>2021-12-11T10:33:24Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy.da.Searchcursor sql_clause</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/arcpy-da-searchcursor-sql-clause/m-p/215393#M7381</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Better yet, use named parameters:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_macro_code jive_text_macro"&gt;updateRows = arcpy.da.UpdateCursor(oesfHydroDislvFC, fieldList, sql_clause=(None, 'ORDER BY SL_WTRTY_CD, RIP_COMBO_UID DESC'))&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 13 Aug 2012 20:51:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/arcpy-da-searchcursor-sql-clause/m-p/215393#M7381</guid>
      <dc:creator>JasonScheirer</dc:creator>
      <dc:date>2012-08-13T20:51:58Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy.da.Searchcursor sql_clause</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/arcpy-da-searchcursor-sql-clause/m-p/215394#M7382</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks Jason...&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Working sytax: &lt;/SPAN&gt;&lt;A href="http://forums.arcgis.com/threads/64580-SQL-sort-parameter-syntax-for-da.cursors?p=223774&amp;amp;viewfull=1#post223774"&gt;http://forums.arcgis.com/threads/64580-SQL-sort-parameter-syntax-for-da.cursors?p=223774&amp;amp;viewfull=1#post223774&lt;/A&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 13 Aug 2012 21:07:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/arcpy-da-searchcursor-sql-clause/m-p/215394#M7382</guid>
      <dc:creator>ChrisSnyder</dc:creator>
      <dc:date>2012-08-13T21:07:23Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy.da.Searchcursor sql_clause</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/arcpy-da-searchcursor-sql-clause/m-p/215395#M7383</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/93056-manual-selection-as-input-parameter-for-a-script?p=330656#post330656"&gt;http://forums.arcgis.com/threads/93056-manual-selection-as-input-parameter-for-a-script?p=330656#post330656&lt;/A&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 26 Sep 2013 15:49:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/arcpy-da-searchcursor-sql-clause/m-p/215395#M7383</guid>
      <dc:creator>oscarespitia</dc:creator>
      <dc:date>2013-09-26T15:49:06Z</dc:date>
    </item>
  </channel>
</rss>

