Hi, I am relatively new to Python and Arcpy and I am getting the below error message when I try to update values in a row in a temporary layer which I have created from an Oracle Spatial table. I believe that it could be related to the fact that you cannot have auto-incremented columns in Oracle tables, but any help would be greatly appreciated.
Traceback (most recent call last):
File "\\xxxxxx.py", line 49, in <module>
cursor.updateRow(row)
RuntimeError: The table does not have an auto-incrementing column.
Here is my code:
import arcpy
#Set environment workspace
arcpy.env.workspace = r"C:\Users\..."
in_table = "TABLE1"
temp_layer = "TABLE1_area"
out_layer= "TABLE1_area.lyr"
temp_wksp= r"\\..."
count = 0
#Generate a temporary table
arcpy.MakeFeatureLayer_management(in_table,temp_layer,workspace=temp_wksp)
#Add a new field to the temporary table
arcpy.AddField_management(temp_layer,"AREA_TEMP","DOUBLE")
arcpy.AddField_management(temp_layer,"UNIQUE_ID","LONG")
fields = ["SHAPE@AREA","AREA_TEMP","UNIQUE_ID"]
#Populate the SHAPE_AREA2 field in each row using a SearchCursor and print out the results.
with arcpy.da.UpdateCursor(temp_layer,fields) as cursor:
for row in cursor:
row[1]=row[0]
row[2]=count
count += 1
print("SHAPE@AREA: {0} AREA_TEMP: {1} UNIQUE_ID: {2}".format(row[0],row[1],row[2]))
cursor.updateRow(row)
del row
del cursor
arcpy.env.workspace = temp_wksp
arcpy.SaveToLayerFile_management(temp_layer, out_layer)