arcpy.da.InsertCursor locking SDE data base

692
1
10-24-2013 01:06 PM
JeremyLuymes
New Contributor III
Hi,

I'm having an issue with using the new da cursors in Arc 10.1. I have a basic script that uses selected features ("watpoints") and copies them to an abandoned layer (watabdev)

arcpy.MakeFeatureLayer_management(point,"watpoints")
with arcpy.da.InsertCursor(watabdev,("SUBTYPE","SHAPE@XY")) as cur:              
    with arcpy.da.SearchCursor("watpoints",["SHAPE@XY"]) as cursor:              
        for row in cursor:
            cur.insertRow((1,row[0]))
del cur, row, cursor


I used with cursors and tried deleting the cursors afterwords. But after I run the tool, arcmap gives me an error that the abandoned layer is in a closed state and I cannot access it.

Any suggestions?

Thanks.
Tags (2)
0 Kudos
1 Reply
RichardFairhurst
MVP Honored Contributor
Hi,

I'm having an issue with using the new da cursors in Arc 10.1. I have a basic script that uses selected features ("watpoints") and copies them to an abandoned layer (watabdev)

arcpy.MakeFeatureLayer_management(point,"watpoints")
with arcpy.da.InsertCursor(watabdev,("SUBTYPE","SHAPE@XY")) as cur:              
    with arcpy.da.SearchCursor("watpoints",["SHAPE@XY"]) as cursor:              
        for row in cursor:
            cur.insertRow((1,row[0]))
del cur, row, cursor


I used with cursors and tried deleting the cursors afterwords. But after I run the tool, arcmap gives me an error that the abandoned layer is in a closed state and I cannot access it.

Any suggestions?

Thanks.


According to the help:

"The advantage of using a With statement is that it will guarantee close and release of database locks and reset iteration regardless of whether the cursor completed successfully or an exception occurred."

That would imply the del statements are not needed.  Have you tried the script without them?
0 Kudos