AnsweredAssumed Answered

how to delete features from the topology layer with arcpy.da

Question asked by HalinaLewandowski on Aug 2, 2017
Latest reply on Apr 17, 2018 by ethanb@npgis.int_npgs2

I'm trying to delete all features from the SDE layer that has topology... the script fails on the arcpy.DeleteFeatures... 


arcgisscripting.ExecuteError: ERROR 999999: Error executing function.
A class in the topology necessitates validation being run within an edit session. [county.GIS_SDE.BldgInsp]
Failed to execute (DeleteFeatures).


Here is what I have:

SDE_bldginsp = county_con + os.sep + "county.GIS_SDE.bldginsp" 

areafield = "SHAPE.area"

 sde_concounty = sdeConnClass.SDE_Connection(gis_server, gis_dbcounty,'gis_sde','gis_sde')
county_con = sde_concounty.connection
gv.SDE_countyconnection = county_con

bldginspSDE_layer = "bldginsp_layer"

arcpy.MakeFeatureLayer_management(SDE_bldginsp, bldginspSDE_layer, "", "", "")
query = areafield + " > 0"
arcpy.SelectLayerByAttribute_management(bldginspSDE_layer, "NEW_SELECTION", query)


   with arcpy.da.Editor(countyconnection) as edit:
     print " deleting old features."
     arcpy.SelectLayerByAttribute_management(bldginspSDE_layer, "NEW_SELECTION", query)
     print "Deleted selected features from bldginsp "

     # APPEND local DORSalTx to SDE DORSalTx...
     fclist = [bldginsp_county_city_erased]
     arcpy.Append_management(fclist, bldginspSDE_layer)

     msg = "bldginsp updated sucessfully"
     print msg
     #print msg

except arcpy.ExecuteError: