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 <SPAN class="operator token">=</SPAN> <SPAN class="punctuation token">[</SPAN><SPAN class="punctuation token">]</SPAN>
add_fields<SPAN class="punctuation token">.</SPAN>append<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">[</SPAN><SPAN class="string token">'CLASS_ID'</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">'LONG'</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">'CLASS_ID'</SPAN><SPAN class="punctuation token">,</SPAN> None<SPAN class="punctuation token">,</SPAN> None<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN>
add_fields<SPAN class="punctuation token">.</SPAN>append<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">[</SPAN><SPAN class="string token">'SUBTYPE_ID'</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">'SHORT'</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">'SUBTYPE_ID'</SPAN><SPAN class="punctuation token">,</SPAN> None<SPAN class="punctuation token">,</SPAN> None<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN>
arcpy<SPAN class="punctuation token">.</SPAN>AddFields_management<SPAN class="punctuation token">(</SPAN><SPAN class="string token">"F:\Projects\root@Demo2.sde/Demo2.ROOT.StructureLine"</SPAN><SPAN class="punctuation token">,</SPAN> add_fields<SPAN class="punctuation token">)</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>
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