Search & Update Cursor

Discussion created by muhammadattique on Feb 17, 2020
Latest reply on Feb 20, 2020 by

Hi ,

I am stuck with SearchCursor and Update Cursor in my code, what's wrong with it , 

the scienrio is . I have a table in which "source" , "sink" and "duplicate" fields available.


  1. Search 1 in field "duplicate"  , read row, save "sink" / "source" to variables.
  2. now initiate update cursor , row where source = sink do update .

the output in not the required one.

even I try with one Updatecursor satify the value and update rows , 

the same of the code is as :


with arcpy.da.SearchCursor(SLDTable,SLDfields) as SC01:
      for SC01R in SC01:
            if SC01R[10]==1:
                  tsource = SC01R[2]
                  tsink = SC01R[3]
                  print SC01R
                  with arcpy.da.UpdateCursor(SLDTable,SLDfields) as updC3:
                        for updC3R in updC3:
                              if updC3R[2]==SC01R[3]:
                                 print updC3R
                                 tsource = updC3R[2]
                                 tsink = updC3R[3]
                                 updC3R[8] = sldpt + 1
                                 updC3R[9] = 'BL1'
                                 updC3R[13] = 'Yes'
                                 sldpt += 1