There are are numerous post on this error, but I can't seem to find a solution for myself. We have a versioned sde and need to add new fields to some of our feature classes and populate them with an updateCursor.

code here:

import arcpy
print('Script Started')

arcpy.env.workspace = r"Database Connections\Connection to gisprd.sde"
edit = arcpy.da.Editor(arcpy.env.workspace)
edit.startEditing(True, False)

fcNames = [

fcs = arcpy.ListFeatureClasses("","","LIPA.Distribution")
print('Starting loop')
for fc in fcs:
    # get feature class name
    name = arcpy.Describe(fc).baseName[5:]
    path = arcpy.Describe(fc).catalogPath
    # only do to the features listed above
    if name in fcNames:
        # Add field to store static object ids
        arcpy.AddField_management(path,'ORIG_OID', 'LONG')
        oid = [] # initalize empty to store objectids
        idx = 0 # initalzie empty index counter to add correct objectid to new field for static oid
        # Use cursors to get actual objectids for features of interest
        print('Starting Search')
        with arcpy.da.SearchCursor(path, ('OBJECTID',)) as cursor:
            for row in cursor:
        print('Search finished, starting update')
        # Iterate update cursor over new field
        with arcpy.da.UpdateCursor(path, ('ORIG_OID',)) as upCursor:
            # for each row update with the correct object id and then increment the counter index
            for row in upCursor:
                row[0] = oid[idx]
                idx += 1
        print('Finished update')
        del cursor
        del upCursor

del edit

I got the following traceback:

for row in upCursor:
RuntimeError: workspace already in transaction mode

Can anyone assist?

links of similar questions:

Debugging RuntimeError: workspace already in transaction mode from arcpy.da.UpdateCursor and ArcSDE feature classes?

Workspace already in transaction mode

  • The above two are both trying to work in different versions. We only do stuff like this on weekends after all the work is done for the week, everything has been reconciled and compressed (database is at state 0; not worried about versions).

Checking via ArcPy if ArcMap is in edit session?

  • This one seems to indicate that error means an edit session is not open? So maybe I am setting up the editor wrong?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.