AnsweredAssumed Answered

Using SearchCursor with UpdateCursor

Question asked by MCusumano on Aug 30, 2012
Latest reply on Apr 12, 2013 by MCusumano
Hello, I'm trying to use an UpdateCursor inside of a SearchCursor to populate sequence numbers on an inspection table according to a parcitular UserID. Basically the SearchCursor iterates through a small table with a list of about 29 user ID's (the table changes over time) and uses the values in the where_clause of the updatecursor.

The UpdateCursor sorts the order of the input table based on a structure number and populates the sequences from 1 to 0. Here is the code I have tried:

techrows = arcpy.SearchCursor(psegGasGDB_InputPrefix + "ASSIGNED_TECHS")  for row in techrows:      if TechID != row.ASSIGNED_USER:          TechID = row.ASSIGNED_USER         where_clause = "ASSIGNED_USER = " + TechID         rows = arcpy.UpdateCursor(CONVERSION_InputPrefix + "CPTestPointInspection", where_clause, "SEQ_NO; GAS_CORR_STRUCT_NO", "GAS_CORR_STRUCT_NO")          for row in rows:              try:                        print row                        stop = 1                        row.SetValue("SEQ_NO", stop)                         stop = stop + 1               except Exception as e:                   print e                   logging.error(": %s" %(e))          del rows     del techrows 

But this gives an "Error 999999: Index passed was not within the valid range". Can't figure out what I'm doing wrong...