<?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 da cursor behaviour on layers with where clause in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/da-cursor-behaviour-on-layers-with-where-clause/m-p/113170#M8836</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I can't seem to find any reference to this in help or forums, but it seems a da cursor cannot apply a where clause to a layer with a where clause already applied. Does anyone know if this is this working as intended behaviour or a bug?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Here is some test code where this occurred.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;import arcpy&amp;nbsp; data = r'D:\GIS\DataBase\misc.gdb\CLI_N' lyr = 'temp' arcpy.MakeFeatureLayer_management(data, lyr, 'OBJECTID &amp;lt; 100') print(arcpy.GetCount_management(lyr)) count = 0 cursor = arcpy.da.SearchCursor(lyr, 'OBJECTID', 'OBJECTID &amp;lt; 10') for _ in cursor: &amp;nbsp;&amp;nbsp;&amp;nbsp; count += 1 print(count)&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This code returned&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;&amp;gt;&amp;gt;&amp;gt;&amp;nbsp; 99 99&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 16 Jul 2013 16:24:52 GMT</pubDate>
    <dc:creator>MathewCoyle</dc:creator>
    <dc:date>2013-07-16T16:24:52Z</dc:date>
    <item>
      <title>da cursor behaviour on layers with where clause</title>
      <link>https://community.esri.com/t5/python-questions/da-cursor-behaviour-on-layers-with-where-clause/m-p/113170#M8836</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I can't seem to find any reference to this in help or forums, but it seems a da cursor cannot apply a where clause to a layer with a where clause already applied. Does anyone know if this is this working as intended behaviour or a bug?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Here is some test code where this occurred.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;import arcpy&amp;nbsp; data = r'D:\GIS\DataBase\misc.gdb\CLI_N' lyr = 'temp' arcpy.MakeFeatureLayer_management(data, lyr, 'OBJECTID &amp;lt; 100') print(arcpy.GetCount_management(lyr)) count = 0 cursor = arcpy.da.SearchCursor(lyr, 'OBJECTID', 'OBJECTID &amp;lt; 10') for _ in cursor: &amp;nbsp;&amp;nbsp;&amp;nbsp; count += 1 print(count)&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This code returned&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;&amp;gt;&amp;gt;&amp;gt;&amp;nbsp; 99 99&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 16 Jul 2013 16:24:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/da-cursor-behaviour-on-layers-with-where-clause/m-p/113170#M8836</guid>
      <dc:creator>MathewCoyle</dc:creator>
      <dc:date>2013-07-16T16:24:52Z</dc:date>
    </item>
    <item>
      <title>Re: da cursor behaviour on layers with where clause</title>
      <link>https://community.esri.com/t5/python-questions/da-cursor-behaviour-on-layers-with-where-clause/m-p/113171#M8837</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;do you only have 99 features in that fc?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I can't seem to get the where clause to take on my FC, it always returns all records in the data.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;It seems to work if I put my where clause on a different field, but can't get it to honor a where clause on OBJECTID ?????&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;R_&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 16 Jul 2013 17:37:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/da-cursor-behaviour-on-layers-with-where-clause/m-p/113171#M8837</guid>
      <dc:creator>RhettZufelt</dc:creator>
      <dc:date>2013-07-16T17:37:27Z</dc:date>
    </item>
    <item>
      <title>Re: da cursor behaviour on layers with where clause</title>
      <link>https://community.esri.com/t5/python-questions/da-cursor-behaviour-on-layers-with-where-clause/m-p/113172#M8838</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;do you only have 99 features in that fc?&lt;BR /&gt;&lt;BR /&gt;I can't seem to get the where clause to take on my FC, it always returns all records in the data.&lt;BR /&gt;&lt;BR /&gt;It seems to work if I put my where clause on a different field, but can't get it to honor a where clause on OBJECTID ?????&lt;BR /&gt;&lt;BR /&gt;R_&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;No, I have almost 3000 features in the FC.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 16 Jul 2013 17:40:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/da-cursor-behaviour-on-layers-with-where-clause/m-p/113172#M8838</guid>
      <dc:creator>MathewCoyle</dc:creator>
      <dc:date>2013-07-16T17:40:51Z</dc:date>
    </item>
    <item>
      <title>Re: da cursor behaviour on layers with where clause</title>
      <link>https://community.esri.com/t5/python-questions/da-cursor-behaviour-on-layers-with-where-clause/m-p/113173#M8839</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Weird,&amp;nbsp; if I calculate my "other" field equal to OBJECTID, it won't honor that now either.&amp;nbsp; Set it back to sequential numbers and it works.&amp;nbsp; However, the makefeaturelayer never seems to report the same number of features that the same select query, on the same dataset in ArcMap.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Makefeature either seems to ignore my query and returns all results (as if I use OBJECTID) or, will return fewer results than actually match the query.&amp;nbsp; (Finds 129 where "rec" &amp;lt;= 150 after sequentially calculating the rec field from 1 to 2110)&amp;nbsp; Exact same "select by attributes" in ArcMap returns the 150 that actually match the query.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;R_&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 16 Jul 2013 17:48:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/da-cursor-behaviour-on-layers-with-where-clause/m-p/113173#M8839</guid>
      <dc:creator>RhettZufelt</dc:creator>
      <dc:date>2013-07-16T17:48:36Z</dc:date>
    </item>
    <item>
      <title>Re: da cursor behaviour on layers with where clause</title>
      <link>https://community.esri.com/t5/python-questions/da-cursor-behaviour-on-layers-with-where-clause/m-p/113174#M8840</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Weird,&amp;nbsp; if I calculate my "other" field equal to OBJECTID, it won't honor that now either.&amp;nbsp; Set it back to sequential numbers and it works.&amp;nbsp; However, the makefeaturelayer never seems to report the same number of features that the same select query, on the same dataset in ArcMap.&lt;BR /&gt;&lt;BR /&gt;Makefeature either seems to ignore my query and returns all results (as if I use OBJECTID) or, will return fewer results than actually match the query.&amp;nbsp; (Finds 129 where "rec" &amp;lt;= 150 after sequentially calculating the rec field from 1 to 2110)&amp;nbsp; Exact same "select by attributes" in ArcMap returns the 150 that actually match the query.&lt;BR /&gt;&lt;BR /&gt;R_&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Well that's even weirder.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 16 Jul 2013 17:49:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/da-cursor-behaviour-on-layers-with-where-clause/m-p/113174#M8840</guid>
      <dc:creator>MathewCoyle</dc:creator>
      <dc:date>2013-07-16T17:49:45Z</dc:date>
    </item>
    <item>
      <title>Re: da cursor behaviour on layers with where clause</title>
      <link>https://community.esri.com/t5/python-questions/da-cursor-behaviour-on-layers-with-where-clause/m-p/113175#M8841</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Though, I now see a bunch of weird python stuff going on now.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'd better re-test this after a re-boot......&amp;nbsp; Especially since I know I have had the MakeFeatureLayer working properly in the past..&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;More results later,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;R_&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 16 Jul 2013 17:52:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/da-cursor-behaviour-on-layers-with-where-clause/m-p/113175#M8841</guid>
      <dc:creator>RhettZufelt</dc:creator>
      <dc:date>2013-07-16T17:52:59Z</dc:date>
    </item>
    <item>
      <title>Re: da cursor behaviour on layers with where clause</title>
      <link>https://community.esri.com/t5/python-questions/da-cursor-behaviour-on-layers-with-where-clause/m-p/113176#M8842</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Verified bug that has been fixed in 10.2.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;NIM076948 The arcpy.da.SearchCursor() where clause does not work with a table view&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Work around for 10.1 involved using a select by attribute on the layer with the where clause then running a cursor without a where clause. So editing the initial example that was broken.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;import arcpy&amp;nbsp; data = r'D:\GIS\DataBase\misc.gdb\CLI_N' lyr = 'temp' arcpy.MakeFeatureLayer_management(data, lyr, 'OBJECTID &amp;lt; 100') print(arcpy.GetCount_management(lyr)) count = 0 arcpy.SelectLayerByAttribute_management(lyr, 'NEW_SELECTION', 'OBJECTID &amp;lt; 10') cursor = arcpy.da.SearchCursor(lyr, 'OBJECTID') for _ in cursor: &amp;nbsp;&amp;nbsp;&amp;nbsp; count += 1 arcpy.SelectLayerByAttribute_management(lyr, 'CLEAR_SELECTION') print(count)&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Returns the appropriate.&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;&amp;gt;&amp;gt;&amp;gt;&amp;nbsp; 99 9 &amp;gt;&amp;gt;&amp;gt; &lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 01 Aug 2013 18:49:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/da-cursor-behaviour-on-layers-with-where-clause/m-p/113176#M8842</guid>
      <dc:creator>MathewCoyle</dc:creator>
      <dc:date>2013-08-01T18:49:43Z</dc:date>
    </item>
    <item>
      <title>Re: da cursor behaviour on layers with where clause</title>
      <link>https://community.esri.com/t5/python-questions/da-cursor-behaviour-on-layers-with-where-clause/m-p/113177#M8843</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks for the update.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Sorry I didn't get back to my testing.&amp;nbsp; This fell off the burner.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;R_&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 01 Aug 2013 21:23:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/da-cursor-behaviour-on-layers-with-where-clause/m-p/113177#M8843</guid>
      <dc:creator>RhettZufelt</dc:creator>
      <dc:date>2013-08-01T21:23:23Z</dc:date>
    </item>
  </channel>
</rss>

