AnsweredAssumed Answered

MakeFeatureLayer fails with "where" clause

Question asked by rmartin4 on Aug 16, 2012
Latest reply on Aug 17, 2012 by rmartin4
I posted earlier 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.

This is my code :

# Make feature layer of all points arcpy.MakeFeatureLayer_management("pyServiceConnection", "servLyr")  # Make search cursor with layer rows = arcpy.SearchCursor("servLyr")  # Loop over points for row in rows:          # Make feature layer with the current point only  where = "\"OBJECTID\" = " + str(row.OBJECTID)         arcpy.MakeFeatureLayer_management("servLyr", "curServLyr", where)           # Delete feature layer  arcpy.Delete_management("curServLyr")


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?

Outcomes