<?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: Editing a Versioned SDE FC using python - Error in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/editing-a-versioned-sde-fc-using-python-error/m-p/415186#M32688</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This is a known issue and defect number is #BUG-000114598. It states that "RuntimeError "workspace already in transaction mode" occurs when using da.UpdateCursor on TableView after changing the version."&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Workaround steps are provided below:&lt;/P&gt;&lt;P&gt;1. Change the connection file to point to the desired version.&lt;BR /&gt;2. Use the CreateDatabaseConnection_management tool to generate a temporary connection file pointing to the desired version. Delete when the script finishes.&lt;BR /&gt;3. Use a config file to store the arguments for the CreateDatabaseConnection tool to keep the username and password out of the script.(optional)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is a code snippet used in another&amp;nbsp;user case with similar situation:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;At the beginning of your script:&lt;/P&gt;&lt;P&gt;temp = r"C:\Temp"&lt;BR /&gt;file = "SDEConn"&lt;BR /&gt;arcpy.CreateArcSDEConnectionFile_management(temp, file, &amp;lt;Fill In The Rest With Your RBDMS Parameters&amp;gt;)&lt;BR /&gt;workspace = os.path.join(temp, file +".sde")&lt;BR /&gt;# Set the workspace environment&lt;BR /&gt;env.workspace = workspace&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;At the end of your script:&lt;BR /&gt;arcpy.Delete(workspace)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope that helps.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Biraja&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 23 Apr 2019 22:51:00 GMT</pubDate>
    <dc:creator>BirajaNayak</dc:creator>
    <dc:date>2019-04-23T22:51:00Z</dc:date>
    <item>
      <title>Editing a Versioned SDE FC using python - Error</title>
      <link>https://community.esri.com/t5/python-questions/editing-a-versioned-sde-fc-using-python-error/m-p/415185#M32687</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Getting the following error below when trying to edit a versioned feature class in an SDE database using a python script tool:&lt;/P&gt;&lt;P&gt;Traceback (most recent call last):&lt;BR /&gt; File "L:\Tools\Models\ReconcilePostCalcFields&amp;amp;RecreateVersions.py", line 32, in &amp;lt;module&amp;gt;&lt;BR /&gt; for row in cursor:&lt;BR /&gt;&lt;STRONG&gt;RuntimeError: workspace already in transaction mode&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Code is below:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;import arcpy, os
# Set workspace
workspace = "Database Connections\\Connection to gis-prod.sde"
# Set the workspace environment
arcpy.env.workspace = workspace
# Create Version using SDE credentials
arcpy.CreateVersion_management (workspace, "sde.default", "fieldcalcs", "PUBLIC")
# Delcare variables
##versionList = arcpy.ListVersions('Database Connections\\Connection to gis-prod.sde')
inFeatures = "sde_m.SDE.PARCEL"
zip5expression = "!MAIL_ZIP![0:5]"
fl = "fl"
# Change Workspace to access data via OS Auth.
workspace2 = "Database Connections\\SDE_MPL_PROD_OSAUTH.sde"
arcpy.env.workspace = workspace2
# Create Feature Layer for editing
arcpy.MakeFeatureLayer_management (inFeatures, fl)
# Change Version
arcpy.ChangeVersion_management (fl,"TRANSACTIONAL", "sde.fieldcalcs")
# Start an edit session. Must provide the workspace.
edit = arcpy.da.Editor(workspace2)
# Edit session is started without an undo/redo stack for versioned data
edit.startEditing(False, True)
# Start an edit operation
edit.startOperation()
# Calculate the MAIL_ZIP5 field
fields = ['MAIL_ZIP5']
with arcpy.da.UpdateCursor(fl, fields) as cursor:
	for row in cursor:
		row[0] = zip5expression
		cursor.updateRow(row)	
# Stop the edit operation.
edit.stopOperation()
# Stop the edit session and save the changes
edit.stopEditing(True)‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If I comment out the UpdateCursor section, the script runs successfully. I have also tried to reconcile, post and delete the child versions before executing the script with the same failure, all locks on the database are shared locks. I thought by versioning and editing, I could get around any locking issues. Any idea how to get the workspace out of transaction mode to allow editing to the child version created in the script?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 18:49:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/editing-a-versioned-sde-fc-using-python-error/m-p/415185#M32687</guid>
      <dc:creator>BrittanBattles3</dc:creator>
      <dc:date>2021-12-11T18:49:00Z</dc:date>
    </item>
    <item>
      <title>Re: Editing a Versioned SDE FC using python - Error</title>
      <link>https://community.esri.com/t5/python-questions/editing-a-versioned-sde-fc-using-python-error/m-p/415186#M32688</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This is a known issue and defect number is #BUG-000114598. It states that "RuntimeError "workspace already in transaction mode" occurs when using da.UpdateCursor on TableView after changing the version."&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Workaround steps are provided below:&lt;/P&gt;&lt;P&gt;1. Change the connection file to point to the desired version.&lt;BR /&gt;2. Use the CreateDatabaseConnection_management tool to generate a temporary connection file pointing to the desired version. Delete when the script finishes.&lt;BR /&gt;3. Use a config file to store the arguments for the CreateDatabaseConnection tool to keep the username and password out of the script.(optional)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is a code snippet used in another&amp;nbsp;user case with similar situation:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;At the beginning of your script:&lt;/P&gt;&lt;P&gt;temp = r"C:\Temp"&lt;BR /&gt;file = "SDEConn"&lt;BR /&gt;arcpy.CreateArcSDEConnectionFile_management(temp, file, &amp;lt;Fill In The Rest With Your RBDMS Parameters&amp;gt;)&lt;BR /&gt;workspace = os.path.join(temp, file +".sde")&lt;BR /&gt;# Set the workspace environment&lt;BR /&gt;env.workspace = workspace&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;At the end of your script:&lt;BR /&gt;arcpy.Delete(workspace)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope that helps.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Biraja&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 23 Apr 2019 22:51:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/editing-a-versioned-sde-fc-using-python-error/m-p/415186#M32688</guid>
      <dc:creator>BirajaNayak</dc:creator>
      <dc:date>2019-04-23T22:51:00Z</dc:date>
    </item>
  </channel>
</rss>

