RuntimeError: workspace already in transaction mode

574
1
Jump to solution
11-09-2022 01:52 PM
YinghongLi1
Occasional Contributor

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

0 Kudos
1 Solution

Accepted Solutions
YinghongLi1
Occasional Contributor

I just realized that the connection file the workspace referred too has to pointed to the editing version.  Even if the editing layers are all versioned the database connection file has to do so too.

View solution in original post

0 Kudos
1 Reply
YinghongLi1
Occasional Contributor

I just realized that the connection file the workspace referred too has to pointed to the editing version.  Even if the editing layers are all versioned the database connection file has to do so too.

0 Kudos