Hi All,
I have defined the workspace, started and stopped the edit session, but afterwards, I am getting the Runtime Error (Objects in this class cannot be updated outside an edit session). The layer "CGD. ROAD_LOCATIONS" is versioned.
……….Script (part)……………..
arcpy.env.workspace = r"\\Pas215q4\User Connection\GS-0001.database.windows.net(1).sde"
edit = arcpy.da.Editor(arcpy.env.workspace)
if (edit.isEditing!='True'):
edit.startEditing(True, True)
edit.startOperation()
field = ['SECTION_ID']
found_values = defaultdict(set)
with arcpy.da.UpdateCursor("CGD.ROAD_LOCATIONS", field, "[OBJECTID] > 944861") as cursor:
for row in cursor:
for i, column in enumerate(field):
if row[i] in found_values[column]:
cursor.deleteRow()
break
else:
for column, value in zip(field, row):
found_values[column].add(value)
edit.stopOperation()
edit.stopEditing(True)
................................
When running this it breaks in (“for row in cursor”), and I am getting the following error message,
………..Error message…………
Traceback (most recent call last):
File "P:\Create_Assets.py", line 152, in <module>
main()
File " P:\Create_Assets.py", line 52, in main
for row in cursor:
RuntimeError: Objects in this class cannot be updated outside an edit session [CGD. ROAD_LOCATIONS]
No issue with the indentation, maybe I have missed the proper indent here as I am typing it manually. No issue with the script while running from the admin account, but other user accounts is experiencing the run-time issue.
Great to have your suggestions on how to solve this issue please.
Kind regards,
Shahriar