[Tutor] Editing Data in Non Versioned SDE Using python With An Update Cursor

Peter Otten __peter__ at web.de
Sat Jan 14 05:08:54 EST 2017


Nicole King wrote:

> Hello,
> 
>  
> 
> 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)

After reading 

https://pro.arcgis.com/en/pro-app/arcpy/data-access/updatecursor-class.htm

I would guess that the second argument has to be a list of field names, i. 
e.

updCursor = arcpy.UpdateCursor(
    projectedFC, 
    ["POINT_X", "POINT_Y"], 
    "",
    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 update cursor using python it would be greatly
> appreciated.

The goal of the tutor mailing list is to help newbies with the Python 
language, the standard library, and common external packages.

As yours is a specialist topic you will most likely get better answers when 
you ask questions concerning arcgis on a dedicated mailing list or forum.



More information about the Tutor mailing list