<?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 cursors and layer definition query in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/arcpy-da-cursors-and-layer-definition-query/m-p/461888#M36151</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I'm having the same problem.&amp;nbsp; Someone reported the bug on May 8 (NIM-091487), but there is no information regarding when/if it will be fixed.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Simple workaround:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Include the layer's definition query in the cursor's "where clause" and refer to the layer.dataSource instead of the layer itself when creating the cursor.&amp;nbsp; For example:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This doesn't work:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;MRDroutelogEvents.definitionQuery = "\"TWN_TID\" = '%s'" %twnlr
ghost_query = "\"SR_CATEG\" = 'GHOST'" %twnlr
ghost_points = sorted([item[0] for item in (arcpy.da.SearchCursor(MRDroutelogEvents, ["SR_CATEG"], ghost_query))])
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This does work:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;ghost_query = "\"TWN_TID\" = '%s' AND \"SR_CATEG\" = 'GHOST'" %twnlr
ghost_points = sorted([item[0] for item in (arcpy.da.SearchCursor(MRDroutelogEvents.dataSource, ["SR_CATEG"], ghost_query))]) #(doesn't matter if there is a definition query on MRDroutelogEvents or not)
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 11 Dec 2021 20:31:56 GMT</pubDate>
    <dc:creator>KerryAlley</dc:creator>
    <dc:date>2021-12-11T20:31:56Z</dc:date>
    <item>
      <title>arcpy.da cursors and layer definition query</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-da-cursors-and-layer-definition-query/m-p/461886#M36149</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;In my mxd I found that if I ran an arcpy.da search cursor with a where clause on a layer that had a definition query applied to it, that the where clause would not be honored. Anybody else have this problem?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;George&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 08 Apr 2013 11:04:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-da-cursors-and-layer-definition-query/m-p/461886#M36149</guid>
      <dc:creator>GeorgeNewbury</dc:creator>
      <dc:date>2013-04-08T11:04:51Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy.da cursors and layer definition query</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-da-cursors-and-layer-definition-query/m-p/461887#M36150</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;How do you know that you referenced the layer and not the underlying featureclass? If they have the same name (they do by default) then it might not be clear.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 09 Apr 2013 04:37:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-da-cursors-and-layer-definition-query/m-p/461887#M36150</guid>
      <dc:creator>KimOllivier</dc:creator>
      <dc:date>2013-04-09T04:37:07Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy.da cursors and layer definition query</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-da-cursors-and-layer-definition-query/m-p/461888#M36151</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I'm having the same problem.&amp;nbsp; Someone reported the bug on May 8 (NIM-091487), but there is no information regarding when/if it will be fixed.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Simple workaround:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Include the layer's definition query in the cursor's "where clause" and refer to the layer.dataSource instead of the layer itself when creating the cursor.&amp;nbsp; For example:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This doesn't work:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;MRDroutelogEvents.definitionQuery = "\"TWN_TID\" = '%s'" %twnlr
ghost_query = "\"SR_CATEG\" = 'GHOST'" %twnlr
ghost_points = sorted([item[0] for item in (arcpy.da.SearchCursor(MRDroutelogEvents, ["SR_CATEG"], ghost_query))])
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This does work:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;ghost_query = "\"TWN_TID\" = '%s' AND \"SR_CATEG\" = 'GHOST'" %twnlr
ghost_points = sorted([item[0] for item in (arcpy.da.SearchCursor(MRDroutelogEvents.dataSource, ["SR_CATEG"], ghost_query))]) #(doesn't matter if there is a definition query on MRDroutelogEvents or not)
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 20:31:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-da-cursors-and-layer-definition-query/m-p/461888#M36151</guid>
      <dc:creator>KerryAlley</dc:creator>
      <dc:date>2021-12-11T20:31:56Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy.da cursors and layer definition query</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-da-cursors-and-layer-definition-query/m-p/461889#M36152</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Yes, I logged the following bug:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;NIM091487: The "where clause" in data access cursors is not respected if there is a definition query with more than one argument (complex expression).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;There is unfortunately no indication on when this issue will be addressed. If you log a support ticket and create an incident, we can get you attached to the bug and you can track it on your customer care portal.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 03 Jun 2013 21:46:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-da-cursors-and-layer-definition-query/m-p/461889#M36152</guid>
      <dc:creator>LucasDanzinger</dc:creator>
      <dc:date>2013-06-03T21:46:20Z</dc:date>
    </item>
  </channel>
</rss>

