English

Problem: Unable to edit versioned views with ArcPy or ArcObjects

Description

When editing a versioned view with the ArcPy function Update Cursor, the following exception is returned:

Error:
SystemError: error return without exception set. 

The following is an example of Python code used to edit a versioned view using the updateRow() function.

import arcpy
dbConnection = r'C:\Users\name\AppData\Roaming\ESRI\Desktop10.4\ArcCatalog\sdeconnection.sde'    
tablePath = dbConnection + "\\testdatabase.dataowner.test_evw"
with arcpy.da.UpdateCursor(tablePath, "*") as cur:
    for row in cur:
        row[1] = 3
        cur.updateRow(row)

Cause

This is expected behavior. Versioned views are for applications that do not support geodatabase versioning. Versioned views are not meant to be consumed or modified using ArcPy in ArcObjects, which does not support geodatabase versioning.

Solution or Workaround

Modify the feature class directly using ArcPy. The Python editor function can be used with the workspace pointing to a transactional version, as shown in the following example:

import arcpy

#Start of parameters to change
path = r'C:\temp'
connection = "testversion.sde"
fc = "dataowner.test"
instance = "machinename"
username, password = "owner1", "owner1"
database = "testdatabase"
version = "dataowner.testversion"
#End of parameters to change
#There are more parameters in arcpy.CreateDatabaseConnection_management that we may wish to modify.

tablePath = path + "\\" + connection + "\\" + fc
arcpy.CreateDatabaseConnection_management(path, connection, "SQL_SERVER", instance, "DATABASE_AUTH", username, password, "SAVE_USERNAME", database, "", "TRANSACTIONAL", version)   
editor = arcpy.da.Editor(path + "\\" + connection )        
editor.startEditing() 
editor.startOperation()
with arcpy.da.UpdateCursor(tablePath, "*") as cur:
    for row in cur:
        row[1] = 3
        cur.updateRow(row)    
editor.stopOperation() 
editor.stopEditing(True)

If the versioned view must be edited with Python, note that Python is capable of executing SQL statements. For example, ArcSDESQLExecute is an alternative to edit versioned views. For more information about ArcSDESQLExecute, refer to the following web help document, ArcGIS Desktop Help: ArcSDESQLExecute. Additionally, there are other modules that may be used to connect and modify tables in a database (for example, cx_Oracle for Oracle).

Related Information