AnsweredAssumed Answered

update attribute table from another table based on a query

Question asked by Henseki on Nov 16, 2017
Latest reply on Nov 21, 2017 by xander_bakker

Here is my script

 

import arcpy
... from arcpy import env
... env.workspace = "C:\\Data"
... print 'Processing...'
... fc = "Updated_subset.dbf"
... cursor = arcpy.da.SearchCursor(fc, ["OID"])
... for row in cursor:
...     SQL_stat= "OID = "+ str(row[0])
...     fc2 = "airports_old.dbf"
...     cursor2 = arcpy.da.SearchCursor(fc, ["STATE"], SQL_stat)
...     for row2 in cursor2:
...         UpdatedValue = row2[0]
...         cursor3 = arcpy.da.UpdateCursor(fc2, ["STATE"],SQL_stat)
...         for row3 in cursor3:
...             row3[0] = UpdatedValue
...             cursor3.updateRow(row3)
... del row
... del cursor
... del row2
... del cursor2
... del row3
... del cursor3
...
... print "Done"

 

 

 

 

At the moment the script below  the OID is coneverted to string

SQL_stat= "OID = "+ str(row[0])

 

How do I rewrite the SQL stat if the OID Field is already a string, hence, don't need to convert to string

 

Thanks for your help!

Outcomes