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<SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>
This is the python code I'm running.
<SPAN class="keyword token">import</SPAN> arcpy
fc <SPAN class="operator token">=</SPAN> r<SPAN class="string token">'\\path\to\versioned\feature class'</SPAN>
ws <SPAN class="operator token">=</SPAN> r<SPAN class="string token">'\\path\to\egdb'</SPAN>
select <SPAN class="operator token">=</SPAN> <SPAN class="string token">"UNIQUE_ID = '0' Or UNIQUE_ID IS NULL"</SPAN>
edit <SPAN class="operator token">=</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>da<SPAN class="punctuation token">.</SPAN>Editor<SPAN class="punctuation token">(</SPAN>ws<SPAN class="punctuation token">)</SPAN>
edit<SPAN class="punctuation token">.</SPAN>startEditing<SPAN class="punctuation token">(</SPAN><SPAN class="token boolean">False</SPAN><SPAN class="punctuation token">,</SPAN><SPAN class="token boolean">False</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="comment token"># changed to True, False for versioned feature class</SPAN>
edit<SPAN class="punctuation token">.</SPAN>startOperation<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN>
x <SPAN class="operator token">=</SPAN> <SPAN class="number token">10100000</SPAN>
<SPAN class="keyword token">with</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>da<SPAN class="punctuation token">.</SPAN>UpdateCursor<SPAN class="punctuation token">(</SPAN>fc<SPAN class="punctuation token">,</SPAN><SPAN class="string token">'UNIQUE_ID'</SPAN><SPAN class="punctuation token">,</SPAN>select<SPAN class="punctuation token">)</SPAN><SPAN class="keyword token">as</SPAN> cursor<SPAN class="punctuation token">:</SPAN>
<SPAN class="keyword token">for</SPAN> row <SPAN class="keyword token">in</SPAN> cursor<SPAN class="punctuation token">:</SPAN>
t <SPAN class="operator token">=</SPAN> str<SPAN class="punctuation token">(</SPAN>x<SPAN class="punctuation token">)</SPAN>
row<SPAN class="punctuation token">[</SPAN><SPAN class="number token">0</SPAN><SPAN class="punctuation token">]</SPAN> <SPAN class="operator token">=</SPAN> t
cursor<SPAN class="punctuation token">.</SPAN>updateRow<SPAN class="punctuation token">(</SPAN>row<SPAN class="punctuation token">)</SPAN>
x<SPAN class="operator token">+=</SPAN><SPAN class="number token">1</SPAN>
edit<SPAN class="punctuation token">.</SPAN>stopOperation<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN>
edit<SPAN class="punctuation token">.</SPAN>stopEditing<SPAN class="punctuation token">(</SPAN><SPAN class="token boolean">True</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>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:
10100001
10100002
10100003
...
10103858
What am I doing wrong here?