Delete a feature class from a SDE database failed

1258
15
06-11-2020 11:45 AM
YuLuo
by
New Contributor II

When I tried to use arcpy.management.Delete(fc) to delete a feature class from a SDE database, it failed with error message " ERROR 000601: Cannot delete ..\SECore_Tools_Testing_sde.DBO.point_windmill.  May be locked by another application. Failed to execute (Delete)." 

Then I add the following code before delete the feature class:

edit = arcpy.da.Editor(arcpy.env.workspace)
edit.startEditing(False, True)
edit.startOperation()

arcpy.management.Delete(fc)

edit.stopOperation()

edit.stopEditing(True)

I got different error message " ERROR 000496: table is being edited. Failed to execute (Delete)."

Please help! Thanks.

0 Kudos
15 Replies
DanPatterson
MVP Esteemed Contributor

Is it in a map?

Did you restart Pro?

Where are you running this? from inside using Pro's python or external?


... sort of retired...
0 Kudos
YuLuo
by
New Contributor II

I am running a python tool inside Pro.

0 Kudos
DanPatterson
MVP Esteemed Contributor

what about the first 2 questions?


... sort of retired...
0 Kudos
YuLuo
by
New Contributor II

I start a Arc Pro and add a new map,  add some feature classes from a SDE database, add my new toolbox in Catalog pan.

0 Kudos
DanPatterson
MVP Esteemed Contributor

If one of the layers you are adding is one you are trying to delete, don't add it and see if you can delete it from the database.

If you are trying to just remove it from the map, then you should be using removeLayer from ...

LayerFile—ArcPy | Documentation 


... sort of retired...
0 Kudos
YuLuo
by
New Contributor II

Thank you, Dan. I tried to start new pro and not add any feature class, then run my tool from the toolbox. It gives me the same errors.

0 Kudos
DanPatterson
MVP Esteemed Contributor

It could be anything, including how you set up your parameters in the toolbox.  A lot more information would be needed


... sort of retired...
0 Kudos
YuLuo
by
New Contributor II

My tool can delete feature class from a FileGeodatabase (*.gdb) but not SDE.

0 Kudos
DanPatterson
MVP Esteemed Contributor

SDE just opens up a whole new set of issues

Good luck


... sort of retired...
0 Kudos