AnsweredAssumed Answered

Need help with editing value in versioned sde. Using arcpy.da.Editor

Question asked by janiceb on Sep 5, 2013
Latest reply on Sep 9, 2013 by janiceb
I have a python script that updates the tiles for a cached basemap using a feature class of polygons for the area of interest. Once the tiles are updated, I would like to update the values in the original feature class, changing the field "Cache" values from yes to no. I have no trouble with updating the tiles based on the feature class. I am having trouble changing the values in the feature class "Cache" field from yes to no.

The feature class is in SDE and is versioned. I am using cursors and da.Editor. ArcGIS 10.1.

I get this error: Objects in this class cannot be updated outside an edit session [GisWork.SDEADM.SectionsToCache]
With this code:
        edit = arcpy.da.Editor(env.workspace)         edit.startEditing(True, True)         edit.startOperation()         #Use an update cursor to update the values. This cursor gets all the records in the SectionsToCache feature class where CACHE = 'Yes'         with arcpy.da.UpdateCursor(inputFeatureClass, fieldName, whereClause) as cursor:             # Update the field value to 'No'              for row in cursor:                 print row[0]                 row[0]= "No"                 cursor.updateRow(row)         edit.stopOperation()         edit.stopEditing(True)


I have tried placing the start and stop operations inside the for loop. I have tried with startEditing(False, True). I tried using with for the editor since this is supposed to eliminate the need to handle the stop and start, I believe, but had the same error.

I have also tried to use CalculateField but the values did not update in the feature class. Since I need to use a Feature Layer, I am not sure if MakeFeatureLayer affects the input feature class. It looks like it did not. I can post my code for this but am more interested in getting this to work using the editor and cursors on the feature class itself.

Does anyone else have this working?

Thanks for any suggestions!
Janice.

Outcomes