UpdateCursor, updateRow not working

521
2
06-11-2013 08:03 PM
Emilbrundage
New Contributor III
I can't figure out why my updateRow is not working. It's supposed to make an update to an entry in field Manufactur if a condition is met (val == xfrkv).

The code runs fine and the arcpy.AddMessages are correct, but the field does not get updated. Any help?

Code snidbit:
   rows = arcpy.UpdateCursor(relloc)
   for row in rows:
      global val
      val = row.getValue(field)
      if val == xfrkv:
         arcpy.AddMessage ("\nRelationship found with table " + relloc + ".")
         row.Manufactur = manu
         rows.updateRow(row)
         arcpy.AddMessage ('\nUpdating table ' + c + '\'s field "Manufactur" with ' + manu + '.\n')
         del row
         del rows
         break
Tags (2)
0 Kudos
2 Replies
DanPatterson_Retired
MVP Emeritus
if val == xfrkv:


should that be a string? if val == "xfrkv": because right now it is a variable
0 Kudos
Emilbrundage
New Contributor III
Ha. I just tried playing with it and it actually works. Apparently updateCursors do not work if a table is open. Good to know. Thanks for the suggestion!
0 Kudos