The requested operation is invalid on a closed state

18066
11
03-25-2015 01:38 PM
ChrisGudeman
New Contributor

I've written a number of python scripts, involving UpdateCursor and InsertCursor, that are meant to be used during an edit session in ArcMap. The workspace is a multi-versioned SDE geodatabase. They scripts work fine as long as I perform at least one manual edit prior to running the script, which runs in ArcToolbox. However, if I begin an edit session and run the script prior to performing a manual edit, I receive an error: "The requested operation is invalid on a closed state."

My understanding of the reference is that unless an edit (either spatial or attribute) is first performed on a feature in the SDE database, the workspace remains in a closed state. I mentioned the workaround above; however, this is necessarily convenient and it's easy to forget. Is there something that can be written into the python script, a function perhaps, that can change the workspace to an open state? This would alleviate the need to perform a manual edit before running the script.

I appreciate any help or suggestions.

Chris

11 Replies
Lake_Worth_BeachAdmin
Frequent Contributor

 what if I am running a scheduled task with this script, how does one save edits? No access to arcmap just running python terminal scheduled script.

0 Kudos
DanNguyen
Emerging Contributor

Hi there, I ran into this problem and was very happy to find this thread. However, I am having trouble implementing the solution into my script.

I am editing in a version in a multiple version SDE environment too, when I added 'arcpy.da.Editor' into my code, the error msg says Editor needs parameter, how do you pass the version being edit into Editor?

Thanks!

0 Kudos