Hello everyone,
I am trying to do a simple edit using Calculate field on a layer in a versioned SDE GDB. I've gotten past a few errors, but now have ran into a new one that I can seem to get past. The error is "Objects in this class cannot be updated outside an edit session". I'm trying to use arcpy.da.Editor, but I seem to be missing something. Any ideas would be greatly appreciated!
I am trying to do a simple edit using Calculate field on a layer in a versioned SDE GDB. I've gotten past a few errors, but now have ran into a new one that I can seem to get past. The error is "Objects in this class cannot be updated outside an edit session". I'm trying to use arcpy.da.Editor, but I seem to be missing something. Any ideas would be greatly appreciated!
Code:
fc = "Database Connections\\CCENTGIS_SCLFinal_PRSCL_test.sde\\prscl_test.SCLADMIN.GMSCL\\prscl_test.SCLADMIN.sclarc"
workspace = "Database Connections\\CCENTGIS_SCLFinal_PRSCL_test.sde"
arcpy.MakeFeatureLayer_management(fc, "sclarc_layer")
edit = arcpy.da.Editor(workspace)
edit.startEditing()
edit.startOperation()
with arcpy.da.Editor(workspace) as edit:
arcpy.CalculateField_management("sclarc_layer", "STRNAME", "!strname!.strip", "PYTHON_9.3", "")
edit.stopOperation()
edit.stopEditing(True)