AnsweredAssumed Answered

Trying to edit a layer in a versioned SDE GDB in a Python stand-alone script

Question asked by jdempsey on Jul 17, 2013
Latest reply on Jul 18, 2013 by jdempsey
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!

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) 

Outcomes