I got "RuntimeError: workspace already in transaction mode" in the code listed below. I have been using the similar lines of the code in other scripts and i had never got this problem.
The database is a versioned SDE database (Oracle). Please help.
Thanks😢😢😢😢
Code:
arcpy.env.workspace = r'in_memory\split'
arcpy.env.addOutputsToMap = False
arcpy.env.overwriteOutput = True
arcpy.AddMessage("start process")
aprx = arcpy.mp.ArcGISProject("CURRENT")
currentmap = aprx.activeMap
address_layer=None
address_flds=["OBJECTID", "PLACE_ID", "DUF_POLY_ID"]
layer=None
layers = currentmap.listLayers()
for lyr in layers:
print("layer name=="+lyr.name)
if ("address_point" in lyr.name.lower()):
address_layer=lyr
break
workspace_sde=r"C:\Users\liy\AppData\Roaming\Esri\ArcGISPro\Favorites\MYCONNECTION@giswpdtest.SDE"
edit = arcpy.da.Editor(workspace_sde)
edit.startEditing(False, True)
edit.startOperation()
#there is an address point selected
with arcpy.da.UpdateCursor(address_layer, address_flds) as ucur:
print ("before update")
for urow in ucur:
print ("inside row looping")
urow[2]=151802
ucur.updateRow(urow)
print("update is done")
edit.stopOperation()
edit.stopEditing(True)
Error message
Traceback (most recent call last):
File "<string>", line 26, in <module>
RuntimeError: workspace already in transaction mode