I have a python script that calculates x coordinates , y coordinates for a point geometry that sits within a feature dataset of an SDE (SQL Express). The script worked fine on a file geodatabase however when it runs on the SDE feature class, it stalls at the updateCursor function.
"ERROR: 999999: Error executing function....Objects in the class cannot be updated outside an edit session [FSB.DBO.Structures]"
The script breaks on updCursor.updateRow(row):
workspace = arcpy.env.workspace ="insertworkspace" edit = arcpy.da.Editor(workspace) edit.startEditing(False, True) edit.startOperation() updCursor = arcpy.UpdateCursor(projectedFC,"", spatialRef) for row in updCursor: pnt = row.Shape.getPart(0) row.POINT_X = pnt.X row.POINT_Y = pnt.Y updCursor.updateRow(row) del updCursor, row edit.stopOperation() edit.stopEditing(True)
If anyone has any information, ideas or input on editing data in non versioned SDE with a updatecursor using python it would be greatly appreciated.
Jennifer, it would help if you look at https://community.esri.com/people/curtvprice/blog/2014/09/25/posting-code-blocks-in-the-new-geonet?s... and repost your code. Spacing/indenting is critical in python and debugging for other is hard when that would be the issue.
I would look thru the samples Editor—Help | ArcGIS for Desktop but with a quick look, I would suggest 1) full path to the feature class, and 2) you may need to use MakeFeatureLayer.
but if you are just trying to update coordinates values in the table (not moving the points themselves) maybe look at
Hi Jennifer McCarthy the below should work on a Non-Versioned SDE Geodatabase:
# Start an edit session. Must provide the workspace. edit = arcpy.da.Editor(workspace) # Edit session is started without an undo/redo stack for versioned data # (for second argument, use False for unversioned data) edit.startEditing(True, False) with arcpy.da.UpdateCursor("Your Parameters") as cursor: # Start an edit operation edit.startOperation() for row in cursor: # Your Code Here
# Stop the edit operation. edit.stopOperation() # Stop the edit session and save the changes edit.stopEditing(True)