Error using AddFields_management: Invalid Long type

1782
2
02-27-2018 09:40 AM
KarlHuber
New Contributor III

Hi,

I'm trying to add a couple of fields using the "AddFields_management" from the arcpy that comes with ArcGIS Pro. But when I try to do so, I get an error message that tells me:

arcgisscripting.ExecuteError: ERROR 000378: Invalid Long type.
ERROR 000852: Cannot add field CLASS_ID to F:\Projects\root@Demo2.sde/Demo2.ROOT.StructureLine

What I'm, trying to do is:

add_fields = []
add_fields.append(['CLASS_ID', 'LONG', 'CLASS_ID', None, None)])
add_fields.append(['SUBTYPE_ID', 'SHORT', 'SUBTYPE_ID', None, None)])
arcpy.AddFields_management("F:\Projects\root@Demo2.sde/Demo2.ROOT.StructureLine", add_fields)

I'm lost here. I have no idea why I'm not able to add this field. Interesting: When I'm going to add those fields sequentially using arcpy.AddField_management everything works as expected. Unfortunatelly this is not an option, since I'm going to add a lot of fields to that table (more than 40), which costs a lot of time when I'm doing it field after field (more than a hour per table!)

Do you have any ideas how to use arcpy.AddFields_management properly?

Thanks in advance!

Karl

0 Kudos
2 Replies
DanPatterson_Retired
MVP Emeritus

Other than 3 of the parameters that the single Add Field enables you to set explicitly, the AddFieldSS set those three to default values, innocuous selections.  The only thing that I notice is that you are working on a non-local file (your sde path).  Could you see whether the same procedure of adding fields of the same type to a locally stored geodatabase is successful or not.  It may not be what is being added that is the issue but where it is being added.  This is even though you indicate that a single add field works with the file you are using.  Perhaps AddFields has something else going on (or it is a bug)

0 Kudos
KarlHuber
New Contributor III

Thanks Dan, actually I'm working on a SDE, trying to setup an Utility Network. I'll check the issue with my staging file geodatabase and give you some feedback soon...

0 Kudos