Truncate Table/Non-versioned FC/stand alone script and in Pro ERROR 160592

3802
5
Jump to solution
07-14-2021 10:17 AM
Labels (2)
by Anonymous User
Not applicable

I have a script that performs a truncate and append on a feature class in an enterprise gdb. The feature class is not in a feature dataset, it is not versioned, and it is not open in any map/catalog session. It does feed a map service hosted on Portal. I stop the map service before attempting the truncate.

The error "160592: Truncation not allowed while editing." is thrown when running the script (python 3.7) or when running truncate table within ArcGIS Pro. This error does not occur when running in ArcMap (I have not tried in a stand alone script python 2.7). I have tried using the Editor class to start and stop and edit session before running the truncate, thinking it might do the trick, but no luck. 

I have a hunch this is caused by ArcGIS Pro's "always in an edit session" feature. Has anyone else experienced this, found a work around, or have any ideas of other things to check/try? Thanks! 

1 Solution

Accepted Solutions
by Anonymous User
Not applicable

Esri just confirmed truncate table does not work with feature class that participate in a composite relationship class and therefore, it also does not work with feature classes that have attachments enabled (by default, enabling attachments creates a composite relationship class). Simple relationship classes are supported. 

View solution in original post

5 Replies
DanPatterson
MVP Esteemed Contributor

No known solution .... from here

160592: Truncation not allowed while editing.—ArcGIS Pro | Documentation

Other errors on Tech Support around Truncate Table suggest to use Delete rows instead.


... sort of retired...
0 Kudos
by Anonymous User
Not applicable

I've reverted to delete rows for now, but truncate would be preferred for speed. 

0 Kudos
DanPatterson
MVP Esteemed Contributor

While you are waiting, you should file a bug report


... sort of retired...
by Anonymous User
Not applicable

Esri just confirmed truncate table does not work with feature class that participate in a composite relationship class and therefore, it also does not work with feature classes that have attachments enabled (by default, enabling attachments creates a composite relationship class). Simple relationship classes are supported. 

DavidTillberg_community
New Contributor II

This actually is supported.  When Feature Class contains attachments, you need to use an arcpy.ad.Editor to do certain edit operations (even if it is not versioned).  So to have this work:

    edit = arcpy.da.Editor(SDE_workspace)

    edit.startEditing(False, True) # (or whatever scenario you are comfortable with)

    arcpy.TruncateTable_management(feature_class)

    edit.stopEditing(True)

# and it works!