AnsweredAssumed Answered

Trouble with UpdateCursor.updateRow()

Question asked by jread on Apr 7, 2013
Latest reply on Apr 9, 2013 by rafaelr
I am trying to update an SDE feature class based on another SDE feature class using an Update Cursor.  Th feature classes have identical fields and the same number of records.  There is a "LASTMODIFIED" date field that is changed anytime a record is updated in the source feature class. 

What I'm doing is matching up the rows in each table using their "ID" field, then checking to see if the "LASTMODIFIED" date is different.  If it is different, then I want to update the entire row of the target feature class with the row from the source feature class.

For some reason, this is not working.  The script runs without error, and I've inserted counters to make sure it is finding cases where the last modified dates are different (it is).  However, when I check the records of the target dataset after the script has run, no data has been changed at all.

Does anyone know why this is happening?  I want the entire record to be replaced with the source FCC record, and I thought updateRow() would do that.  The only other thing I can think of is to delete the existing record and insert the record I want in its place, but that seems kind of stupid to me.

sourceFCCur = arcpy.UpdateCursor(SourceFCPath) for sourceFCRow in sourceFCCur:     targetFCCur = arcpy.UpdateCursor(TargetFCPath)     for targetFCRow in targetFCCur:         if targetFCRow.ID == sourceFCRow.ID:             sourceFCDate = sourceFCRow.getValue('LASTMODIFIED')             targetFCDate = targetFCRow.getValue('LASTMODIFIED')             if sourceFCDate != targetFCDate:                 targetFCCur.updateRow(targetFCRow)     del targetFCCur

Outcomes