Select to view content in your preferred language

Appending to a layer with attachments in an unversioned sde database

1648
7
04-19-2019 03:25 PM
DanielWebb
Frequent Contributor

I’m not sure what I’m doing wrong but I’m trying to use a Python script to append to a layer with attachments to an unversioned sde.  I originally got errors saying that had to be during an edit session.  So I added this code to start an edit session.

edit = arcpy.da.Editor(workspace)
 edit.startEditing(False, False)
 edit.startOperation()
 arcpy.Append_management(srcData, destDataSDE, "NO_TEST")
 edit.stopOperation()
 edit.stopEditing(True)

But now I’m getting contradictory errors on the same attempt to run the script.

Objects in this class cannot be updated outside an edit session [<feature class>]
This operation is not allowed while editing [sde.DEFAULT]

 

It "cannot be updated outside an edit session" and the "operation is not allowed while editing"?  I don’t understand.

If anyone has any ideas of what I might be doing wrong, I would appreciate it.

Thanks!

0 Kudos
7 Replies
JoeBorgione
MVP Emeritus

Can you/the user running the script do what you want to in ArcMap?  Just wondering if it's a permission issue with sde.default.

That should just about do it....
0 Kudos
DanielWebb
Frequent Contributor

Hi Joe, thanks for the response.

In ArcMap, when I try to start an edit session, a popup says "Incorrect edit version type."

Since it's unversioned, in the Editing Options I unchecked "Edit a version of the database with the ability to undo and redo."  Also, I'm connecting as the data owner.  Not sure if any of that helps.

We have a staging database with no services published off it and it is also giving me the same errors.

0 Kudos
JoeBorgione
MVP Emeritus

I think 'This operation is not allowed while editing [sde.DEFAULT]' is referring to the Append command; see what happens if you drop the da.Editor sequence and just append.

That should just about do it....
0 Kudos
DanielWebb
Frequent Contributor

When I remove the da.Editor I get this error;

Objects in this class cannot be updated outside an edit session [<feature class>]
Failed to execute (Append).

That's what originally got me looking into using the da.Editor. I feel like it's the attachments portion causing complexities.  We update publication data nightly with Truncate/Appends and don't need edit sessions.  A file geodatabase feature class with attachments also doesn't need an edit session.  This is the first time I'm trying this with a feature class that has attachments so I feel like I'm missing an essential ingredient.

0 Kudos
JoeBorgione
MVP Emeritus

We update publication data nightly with Truncate/Appends and don't need edit sessions.   Which is something we do as well... 

Attachments and eGDBs....  I just don't have any experience in that particular scenario.

That should just about do it....
0 Kudos
DanielWebb
Frequent Contributor

Nor do I.  If you have any "ah ha!' moments, let me know.  I'll keep testing and digging.  Thanks for your help.

0 Kudos
AaronKoelker
Frequent Contributor

Did you ever figure this issue out? I'm having the exact same problem trying to do a truncate and append.

-Aaron
0 Kudos