I'm trying to update a character type field by incrementing numbers but I'm getting:
Traceback (most recent call last): File "<ipython-input-1-33b310f15b18>", line 11, in <module> with arcpy.da.UpdateCursor(fc,'UNIQUE_ID',select)as cursor: TypeError: cannot update the table
This is the python code I'm running.
import arcpy fc = r'\\path\to\versioned\feature class' ws = r'\\path\to\egdb' select = "UNIQUE_ID = '0' Or UNIQUE_ID IS NULL" edit = arcpy.da.Editor(ws) edit.startEditing(False,False) # changed to True, False for versioned feature class edit.startOperation() x = 10100000 with arcpy.da.UpdateCursor(fc,'UNIQUE_ID',select)as cursor: for row in cursor: t = str(x) row = t cursor.updateRow(row) x+=1 edit.stopOperation() edit.stopEditing(True)
As indicated in the title, this feature class is registered as versioned in an egdb. If I unregister the feature class as versioned, it works just fine.
Bottom line is I need to update aa character type of field for 3,858 records by incrementing a number by 1 such that the final field value will look like records:
What am I doing wrong here?
I'm not sure what I mean either! Think I confused the geodatabase versioned view with the versioned FC (luckily and evidently I have no dealings with versioning day-to-day) and thought that the geodatabase connection properties being set to the version might be in the .sde connection file.
I do remember now reading something about the with statement causing issues on cursors for versioned stuff?
Thanks for the interest nine the less: we have two egdb's, test and live. In test, the feature class is unversioned, and luckily for me there is another unique value field that is populated. I created a table of the other unique id field and the (emtpy) unique field I need to populate and ran an update cursor as shown in my code on that table. Then I joined that table to the live egdb feature class and calculated my target field with the joined field values Done...