AnsweredAssumed Answered

Issue when trying to update row using Update cursor

Question asked by naomiang on Apr 4, 2017
Latest reply on Apr 5, 2017 by bixb0012

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 "\\", line 49, in <module>
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


#Add a new field to the temporary table




#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:
        count += 1
        print("SHAPE@AREA: {0} AREA_TEMP: {1} UNIQUE_ID: {2}".format(row[0],row[1],row[2]))
        del row


del cursor


arcpy.env.workspace = temp_wksp


arcpy.SaveToLayerFile_management(temp_layer, out_layer)