AnsweredAssumed Answered

Bug: CalculateField errors after AlterField Tool

Question asked by sbuscher on Jan 9, 2017
Latest reply on Jan 10, 2017 by sbuscher

There looks to be a bug with running the CalculateField tool directly after the AlterField tool via arcpy. AlterField runs successful, but as shown in red below, CalculateField fails with a 'column not found' error. The column listed in the error is not what was altered, it always happens to be the first column in the feature class. 

 

The environment is ArcGIS 10.3.1, 64-bit Python, ArcSDE 10.3.1 on SQL Server 2008. For security\privacy I replaced the arguments in the script. You can substitute your own SDE data to get the same result. 

 

# Script

import arcpy

arcpy.env.workspace = "../some_sde_connection.sde"

arcpy.AlterField_management("InputFeatureClass", "OriginalFieldName", "NewFieldName", "NewFieldName")

arcpy.CalculateField_management("InputFeatureClass", "AnotherField", "Foo", "PYTHON_9.3")

 

C:\projects\>alter_table_bug.py
Traceback (most recent call last):
File "C:\projects\OPS_Int_ArcGIS\source\scripts\alter_table_bug.py", line 15, in <module>
"PYTHON_9.3")
File "C:\Program Files (x86)\ArcGIS\Desktop10.3\ArcPy\arcpy\management.py", line 3457, in CalculateField
raise e
arcgisscripting.ExecuteError: ERROR 999999: Error executing function.
Attribute column not found [42S22:[Microsoft][SQL Server Native Client 11.0][SQL Server]Invalid column name 'TheFirstColumnInTheTable'.] [Database.SchemaName.InputFeatureClass][STATE_ID = 0]
Failed to execute (CalculateField).

Outcomes