<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Bug: CalculateField errors after AlterField Tool in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/bug-calculatefield-errors-after-alterfield-tool/m-p/559027#M43708</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Based on Joshua's suggestion, you might try duplicating your process against a file geodatabase instead of SDE where there probably would be no caching. &amp;nbsp;If it works in the file geodatabase, then it would most likely (not definitely) be the caching of SDE that is causing your issue.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 10 Jan 2017 14:15:03 GMT</pubDate>
    <dc:creator>MichaelVolz</dc:creator>
    <dc:date>2017-01-10T14:15:03Z</dc:date>
    <item>
      <title>Bug: CalculateField errors after AlterField Tool</title>
      <link>https://community.esri.com/t5/python-questions/bug-calculatefield-errors-after-alterfield-tool/m-p/559023#M43704</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;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.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;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.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;# Script&lt;/P&gt;&lt;P&gt;import arcpy&lt;/P&gt;&lt;P&gt;arcpy.env.workspace = "../some_sde_connection.sde"&lt;/P&gt;&lt;P&gt;arcpy.AlterField_management("InputFeatureClass", "OriginalFieldName", "NewFieldName", "NewFieldName")&lt;/P&gt;&lt;P&gt;arcpy.CalculateField_management("InputFeatureClass", "AnotherField", "Foo", "PYTHON_9.3")&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;C:\projects\&amp;gt;alter_table_bug.py&lt;BR /&gt;&lt;SPAN style="color: #ff0000;"&gt;Traceback (most recent call last):&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #ff0000;"&gt; File "C:\projects\OPS_Int_ArcGIS\source\scripts\alter_table_bug.py", line 15, in &amp;lt;module&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #ff0000;"&gt; "PYTHON_9.3")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #ff0000;"&gt; File "C:\Program Files (x86)\ArcGIS\Desktop10.3\ArcPy\arcpy\management.py", line 3457, in CalculateField&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #ff0000;"&gt; raise e&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #ff0000;"&gt;arcgisscripting.ExecuteError: ERROR 999999: Error executing function.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #ff0000;"&gt;Attribute column not found [42S22:[Microsoft][SQL Server Native Client 11.0][SQL Server]Invalid column name 'TheFirstColumnInTheTable'.] [Database.SchemaName.InputFeatureClass][STATE_ID = 0]&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #ff0000;"&gt;Failed to execute (CalculateField).&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 09 Jan 2017 21:12:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/bug-calculatefield-errors-after-alterfield-tool/m-p/559023#M43704</guid>
      <dc:creator>ShaneBuscher</dc:creator>
      <dc:date>2017-01-09T21:12:38Z</dc:date>
    </item>
    <item>
      <title>Re: Bug: CalculateField errors after AlterField Tool</title>
      <link>https://community.esri.com/t5/python-questions/bug-calculatefield-errors-after-alterfield-tool/m-p/559024#M43705</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;can you rule out a slow server by putting a 'time.sleep(2)' (import time first) into your script. &amp;nbsp;The field names may be changed, but I can't remember if the order is altered or what the alias is changed to. &amp;nbsp;If a script nap doesnt work, try to separate the process completely. &amp;nbsp;If sleep and separation doesn't work, then there is a deeper issue.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 09 Jan 2017 22:28:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/bug-calculatefield-errors-after-alterfield-tool/m-p/559024#M43705</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2017-01-09T22:28:06Z</dc:date>
    </item>
    <item>
      <title>Re: Bug: CalculateField errors after AlterField Tool</title>
      <link>https://community.esri.com/t5/python-questions/bug-calculatefield-errors-after-alterfield-tool/m-p/559025#M43706</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Check out &lt;A href="http://desktop.arcgis.com/en/arcmap/latest/tools/data-management-toolbox/clear-workspace-cache.htm"&gt;Clear Workspace Cache&lt;/A&gt;.&amp;nbsp; When connecting to enterprise geodatabases, ArcGIS (not just ArcPy) caches information about the enterprise geodatabase to improve interaction with the geodatabase.&amp;nbsp; Although I can't say specifically what gets cached (&lt;EM&gt;I know there are some who contribute to the forums who could get much more specific&lt;/EM&gt;), it is likely that table schema are part of it.&amp;nbsp; Since you made changes to a table's schema and then tried to process data in the table, it kicks off that error.&amp;nbsp; I can't remember if this only happens in the application itself or when you run a standalone script as well.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 09 Jan 2017 22:36:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/bug-calculatefield-errors-after-alterfield-tool/m-p/559025#M43706</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2017-01-09T22:36:27Z</dc:date>
    </item>
    <item>
      <title>Re: Bug: CalculateField errors after AlterField Tool</title>
      <link>https://community.esri.com/t5/python-questions/bug-calculatefield-errors-after-alterfield-tool/m-p/559026#M43707</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for the tip Dan but no dice. Even with a delay I get the same error. I also feel that any time a developer needs to put a time delay to make a vendor api work means there is a bug in that api.&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 10 Jan 2017 14:09:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/bug-calculatefield-errors-after-alterfield-tool/m-p/559026#M43707</guid>
      <dc:creator>ShaneBuscher</dc:creator>
      <dc:date>2017-01-10T14:09:57Z</dc:date>
    </item>
    <item>
      <title>Re: Bug: CalculateField errors after AlterField Tool</title>
      <link>https://community.esri.com/t5/python-questions/bug-calculatefield-errors-after-alterfield-tool/m-p/559027#M43708</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Based on Joshua's suggestion, you might try duplicating your process against a file geodatabase instead of SDE where there probably would be no caching. &amp;nbsp;If it works in the file geodatabase, then it would most likely (not definitely) be the caching of SDE that is causing your issue.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 10 Jan 2017 14:15:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/bug-calculatefield-errors-after-alterfield-tool/m-p/559027#M43708</guid>
      <dc:creator>MichaelVolz</dc:creator>
      <dc:date>2017-01-10T14:15:03Z</dc:date>
    </item>
    <item>
      <title>Re: Bug: CalculateField errors after AlterField Tool</title>
      <link>https://community.esri.com/t5/python-questions/bug-calculatefield-errors-after-alterfield-tool/m-p/559028#M43709</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Joshua I unsuccessfully tried to clear the workspace as suggested and received an error of a different kind. Note that I also set the workspace again after clearing it. I believe the vague exception is still a result of the AlterTable tool leaving the feature class in an invalid state.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;C:\projects\OPS_Int_ArcGIS\source\scripts&amp;gt;alter_table_bug.py&lt;BR /&gt;&lt;SPAN style="color: #ff0000;"&gt;Traceback (most recent call last):&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #ff0000;"&gt; File "C:\projects\OPS_Int_ArcGIS\source\scripts\alter_table_bug.py", line 20, in &amp;lt;module&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #ff0000;"&gt; "PYTHON_9.3")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #ff0000;"&gt; File "C:\Program Files (x86)\ArcGIS\Desktop10.3\ArcPy\arcpy\management.py", line 3457, in CalculateField&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #ff0000;"&gt; raise e&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #ff0000;"&gt;arcgisscripting.ExecuteError: ERROR 000539: SyntaxError: unexpected EOF while parsing (&amp;lt;expression&amp;gt;, line 1)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #ff0000;"&gt;Failed to execute (CalculateField).&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 10 Jan 2017 14:24:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/bug-calculatefield-errors-after-alterfield-tool/m-p/559028#M43709</guid>
      <dc:creator>ShaneBuscher</dc:creator>
      <dc:date>2017-01-10T14:24:19Z</dc:date>
    </item>
    <item>
      <title>Re: Bug: CalculateField errors after AlterField Tool</title>
      <link>https://community.esri.com/t5/python-questions/bug-calculatefield-errors-after-alterfield-tool/m-p/559029#M43710</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Cleared the cache and still getting the error. This is looking more like an official bug.&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 10 Jan 2017 14:25:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/bug-calculatefield-errors-after-alterfield-tool/m-p/559029#M43710</guid>
      <dc:creator>ShaneBuscher</dc:creator>
      <dc:date>2017-01-10T14:25:42Z</dc:date>
    </item>
    <item>
      <title>Re: Bug: CalculateField errors after AlterField Tool</title>
      <link>https://community.esri.com/t5/python-questions/bug-calculatefield-errors-after-alterfield-tool/m-p/559030#M43711</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I don't think the exception is necessarily vague.&amp;nbsp; It is saying you have a syntax error with CalculateField, likely from the expression.&amp;nbsp; Can you provide any more details about your expression or call to CalculateField?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 10 Jan 2017 14:26:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/bug-calculatefield-errors-after-alterfield-tool/m-p/559030#M43711</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2017-01-10T14:26:17Z</dc:date>
    </item>
    <item>
      <title>Re: Bug: CalculateField errors after AlterField Tool</title>
      <link>https://community.esri.com/t5/python-questions/bug-calculatefield-errors-after-alterfield-tool/m-p/559031#M43712</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The expression syntax is in my original post, and works fine when not performing an AlterField beforehand.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 10 Jan 2017 15:12:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/bug-calculatefield-errors-after-alterfield-tool/m-p/559031#M43712</guid>
      <dc:creator>ShaneBuscher</dc:creator>
      <dc:date>2017-01-10T15:12:10Z</dc:date>
    </item>
    <item>
      <title>Re: Bug: CalculateField errors after AlterField Tool</title>
      <link>https://community.esri.com/t5/python-questions/bug-calculatefield-errors-after-alterfield-tool/m-p/559032#M43713</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Take a look at this post:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A class="link-titled" href="http://yuluo.me/pitfalls-of-arcpy-2/" title="http://yuluo.me/pitfalls-of-arcpy-2/"&gt;Pitfalls in ArcPy (2)&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It seems to me that you might need to run a script where you alter the field and then close the SDE connection. &amp;nbsp;Then run a second script where the SDE names have been updated so the CalculateField sees the new name of the field.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 10 Jan 2017 15:24:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/bug-calculatefield-errors-after-alterfield-tool/m-p/559032#M43713</guid>
      <dc:creator>MichaelVolz</dc:creator>
      <dc:date>2017-01-10T15:24:22Z</dc:date>
    </item>
    <item>
      <title>Re: Bug: CalculateField errors after AlterField Tool</title>
      <link>https://community.esri.com/t5/python-questions/bug-calculatefield-errors-after-alterfield-tool/m-p/559033#M43714</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I agree in theory with this, and will try. However, I consider this a bug if the AlterField can't be chained with another tool like CalculateField in the same script. If it's not supported, ESRI should give you a graceful message back indicating so instead of a hard exception. Will get back to you on whether or not this works though.&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 10 Jan 2017 15:53:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/bug-calculatefield-errors-after-alterfield-tool/m-p/559033#M43714</guid>
      <dc:creator>ShaneBuscher</dc:creator>
      <dc:date>2017-01-10T15:53:56Z</dc:date>
    </item>
    <item>
      <title>Re: Bug: CalculateField errors after AlterField Tool</title>
      <link>https://community.esri.com/t5/python-questions/bug-calculatefield-errors-after-alterfield-tool/m-p/559034#M43715</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;OK got the CalculateField working after AlterField using ClearWorkspaceCache in between. This didn't work the first time I tried because Joshua Bixby was also correct on the CalculateField- I had the 'expression' parameter incorrectly assigned. It was "foo" and needed to be "'foo'". ClearWorkspaceCache was definitely needed to be run to make both these tools (with proper params) work back-to-back. &amp;nbsp;Thanks!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 10 Jan 2017 16:26:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/bug-calculatefield-errors-after-alterfield-tool/m-p/559034#M43715</guid>
      <dc:creator>ShaneBuscher</dc:creator>
      <dc:date>2017-01-10T16:26:28Z</dc:date>
    </item>
  </channel>
</rss>

