<?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 MakeFeatureLayer fails with &amp;amp;amp;amp;quot;where&amp;amp;amp;amp;quot; clause in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/makefeaturelayer-fails-with-amp-amp-amp-quot-where/m-p/496353#M38975</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I posted &lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="http://forums.arcgis.com/threads/64880-UpdateCursor-fails-after-2-rows" rel="nofollow" target="_blank"&gt;earlier&lt;/A&gt;&lt;SPAN&gt; about UpdateCursor not working, but since then I have narrowed the problem down to MakeFeatureLayer. What I am trying to do is loop over features in a point class and isolate each one into its own layer using a where statement, and then delete the layer before the next iteration. (This is just for diagnostic purposes - not meant to do anything productive.) The problem is that when I give MakeFeatureLayer a where statement, it will only run twice and then stop without any errors or messages.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This is my code :&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;# Make feature layer of all points arcpy.MakeFeatureLayer_management("pyServiceConnection", "servLyr")&amp;nbsp; # Make search cursor with layer rows = arcpy.SearchCursor("servLyr")&amp;nbsp; # Loop over points for row in rows:&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Make feature layer with the current point only&amp;nbsp; where = "\"OBJECTID\" = " + str(row.OBJECTID) &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.MakeFeatureLayer_management("servLyr", "curServLyr", where)&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Delete feature layer&amp;nbsp; arcpy.Delete_management("curServLyr")&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Interestingly, if I leave out the where statement the code will run to completion. I have tried using other where statements such as "1=1" but all of them caused the same fail after the second run. I am totally stumped by this - can anyone think of what could be going on here?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 16 Aug 2012 22:23:25 GMT</pubDate>
    <dc:creator>RobertMartin2</dc:creator>
    <dc:date>2012-08-16T22:23:25Z</dc:date>
    <item>
      <title>MakeFeatureLayer fails with &amp;amp;amp;quot;where&amp;amp;amp;quot; clause</title>
      <link>https://community.esri.com/t5/python-questions/makefeaturelayer-fails-with-amp-amp-amp-quot-where/m-p/496353#M38975</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I posted &lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="http://forums.arcgis.com/threads/64880-UpdateCursor-fails-after-2-rows" rel="nofollow" target="_blank"&gt;earlier&lt;/A&gt;&lt;SPAN&gt; about UpdateCursor not working, but since then I have narrowed the problem down to MakeFeatureLayer. What I am trying to do is loop over features in a point class and isolate each one into its own layer using a where statement, and then delete the layer before the next iteration. (This is just for diagnostic purposes - not meant to do anything productive.) The problem is that when I give MakeFeatureLayer a where statement, it will only run twice and then stop without any errors or messages.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This is my code :&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;# Make feature layer of all points arcpy.MakeFeatureLayer_management("pyServiceConnection", "servLyr")&amp;nbsp; # Make search cursor with layer rows = arcpy.SearchCursor("servLyr")&amp;nbsp; # Loop over points for row in rows:&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Make feature layer with the current point only&amp;nbsp; where = "\"OBJECTID\" = " + str(row.OBJECTID) &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.MakeFeatureLayer_management("servLyr", "curServLyr", where)&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Delete feature layer&amp;nbsp; arcpy.Delete_management("curServLyr")&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Interestingly, if I leave out the where statement the code will run to completion. I have tried using other where statements such as "1=1" but all of them caused the same fail after the second run. I am totally stumped by this - can anyone think of what could be going on here?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Aug 2012 22:23:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/makefeaturelayer-fails-with-amp-amp-amp-quot-where/m-p/496353#M38975</guid>
      <dc:creator>RobertMartin2</dc:creator>
      <dc:date>2012-08-16T22:23:25Z</dc:date>
    </item>
    <item>
      <title>Re: MakeFeatureLayer fails with "where" clause</title>
      <link>https://community.esri.com/t5/python-questions/makefeaturelayer-fails-with-amp-amp-amp-quot-where/m-p/496354#M38976</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;You can't make a layer from the layer you already have open with a cursor. A two-step process may work better for you to get the cursor out of the picture.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;# Make feature layer of all points arcpy.MakeFeatureLayer_management("pyServiceConnection", "servLyr")&amp;nbsp; # Create list of unique object ids rows = arcpy.SearchCursor("servLyr") # Loop over points objIDs = list() for row in rows: &amp;nbsp;&amp;nbsp;&amp;nbsp; objIDs.append(row.OBJECTID) # make list unique objIDs = list(set(objIDs))&amp;nbsp; # Make and delete feature layer for each point one at a time for objID in objIDs: &amp;nbsp;&amp;nbsp;&amp;nbsp; where = "OBJECTID = {0}".format(objID) &amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.MakeFeatureLayer_management("servLyr", "lyr1", where) &amp;nbsp;&amp;nbsp;&amp;nbsp; # Delete feature layer &amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.Delete_management("lyr1")&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 17 Aug 2012 00:40:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/makefeaturelayer-fails-with-amp-amp-amp-quot-where/m-p/496354#M38976</guid>
      <dc:creator>curtvprice</dc:creator>
      <dc:date>2012-08-17T00:40:16Z</dc:date>
    </item>
    <item>
      <title>Re: MakeFeatureLayer fails with "where" clause</title>
      <link>https://community.esri.com/t5/python-questions/makefeaturelayer-fails-with-amp-amp-amp-quot-where/m-p/496355#M38977</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thank you Curtis! This worked without a hitch.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 17 Aug 2012 18:53:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/makefeaturelayer-fails-with-amp-amp-amp-quot-where/m-p/496355#M38977</guid>
      <dc:creator>RobertMartin2</dc:creator>
      <dc:date>2012-08-17T18:53:41Z</dc:date>
    </item>
  </channel>
</rss>

