<?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: UpdateCursor on versioned SDE data failing in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/updatecursor-on-versioned-sde-data-failing/m-p/1201380#M65269</link>
    <description>&lt;P&gt;Think you need to set the editor to True for versioned data:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;edit.startEditing(False, True)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Edited- grabbed the wrong description previously.&lt;/P&gt;&lt;P&gt;From the docs:&lt;/P&gt;&lt;P&gt;When False, you have full control of editing a nonversioned, or versioned dataset. If your dataset is nonversioned and you use &lt;SPAN class=""&gt;stopEditing(False)&lt;/SPAN&gt;, your edit will not be committed (otherwise, if set to True, your edits will be committed).&lt;/P&gt;&lt;P&gt;(The default value is True)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 10 Aug 2022 15:57:37 GMT</pubDate>
    <dc:creator>Anonymous User</dc:creator>
    <dc:date>2022-08-10T15:57:37Z</dc:date>
    <item>
      <title>UpdateCursor on versioned SDE data failing</title>
      <link>https://community.esri.com/t5/python-questions/updatecursor-on-versioned-sde-data-failing/m-p/1201372#M65268</link>
      <description>&lt;P&gt;I am attempting to update utility feature classes with an update cursor. I have several layers I am practically doing this exact thing for and would really like to get it to work but I am stumped.&lt;/P&gt;&lt;P&gt;I have read a few other posts about this issue but they all seem to be older and without applicable solutions to what I am doing. I also found a post stating that this is a known bug/limitation of the update cursor, but is again from several years ago so I'm just not sure if this bug hasn't been fixed yet or if there is something else I am missing.&amp;nbsp; There is no information on the UpdateCursor help documentation about the bug that I have come across.&lt;/P&gt;&lt;P&gt;I first tested all my code on copies of the sde layers that I put into a testing gdb and those all ran without error. However, now that I'm at the point of wanting to implement the script on my production data, I am getting the following error on line 32:&lt;/P&gt;&lt;P&gt;TypeError: cannot update the table&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help or additional insight would be greatly appreciated!&lt;/P&gt;&lt;P&gt;Nicole&lt;/P&gt;&lt;LI-CODE lang="python"&gt;# WORKSPACE FOR EDIT SESSION
workspace = r"C:\Workspace\Default.sde"
# ASSIGN VARIABLE TO SUBDIVISION LAYER
outputSub = r"C:\org.sde\Subdivision"
# ASSIGN VARIABLE TO UTILITY LAYER
outputManhole = r"N:\Workspace\Default.sde\Manhole"

# SPATIAL JOIN SELECTION FC OF SUBDIVISIONS TO UTILITY FEATURES
arcpy.SpatialJoin_analysis(outputManhole, outputSub, outsubSJManhole, "JOIN_ONE_TO_MANY", "KEEP_ALL", "", "CLOSEST", 3000, "DIST")

# CONVERT MM/dd/yyyy TO yyyy ONLY
convertInstall = arcpy.ConvertTimeField_management(outsubSJManhole, "INSTALLDATE", "", "YEAR", "TEXT", "yyyy")

# ASSIGN VARIABLE TO OPEN EDIT SESSION
edit = arcpy.da.Editor(workspace)

# START EDIT SESSION
edit.startEditing(False, False)

# START EDIT OPERATION
edit.startOperation()

# TABLE JOIN OF ORIGINAL UTILITY LAYER TO CONVERTED DATETIME TABLE
InstallJoin = arcpy.AddJoin_management(outputManhole, "FACILITYID", convertInstall, "FACILITYID", "KEEP_ALL")

# ASSIGN VARIABLE TO DICTIONARY
# LIST COMPREHENSION TO FILL DICTIONARY USING SEARCH CURSOR
# KEY IS FACILITY ID TO MATCH RECORDS FROM SPATIAL JOIN
InstallDict = {r[0]: (r[1:]) for r in arcpy.da.SearchCursor(InstallJoin, ["Manhole.FACILITYID", "outsubSJManhole.YEAR"])}

# UPDATE CURSOR IN WITH STATEMENT
with arcpy.da.UpdateCursor(outputManhole, ["FACILITYID", "INSTALLDATE", "YEARBUILT"]) as cursor:
    # FOR EVERY ROW BEING PULLED FROM TABLE
    for row in cursor:
        # IF 'INSTALLDATE' HAS A VALUE
        if row[1] != None:
            # KEY VALUE(FACILITY ID) IN DICTIONARY IS SAME AS FACILITY ID 
              FIELD IN UPDATE CURSOR FIELD
            keyValue = row[0]
            # IF KEY VALUE (FACILITY ID) IS IN THE DICTIONARY
            if keyValue in InstallDict:
                # 'YEARBUILT' IS EQUAL TO THE MATCHING DICTIONARY VALUE 
                   BASED ON FACILITY ID
                row[2] = InstallDict[keyValue][0]
                # CALL TO UPDATE THE ROW WITH THE VALUE
                cursor.updateRow(row)
# DELETE DICTIONARY
del InstallDict&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 10 Aug 2022 15:39:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/updatecursor-on-versioned-sde-data-failing/m-p/1201372#M65268</guid>
      <dc:creator>NicoleV</dc:creator>
      <dc:date>2022-08-10T15:39:06Z</dc:date>
    </item>
    <item>
      <title>Re: UpdateCursor on versioned SDE data failing</title>
      <link>https://community.esri.com/t5/python-questions/updatecursor-on-versioned-sde-data-failing/m-p/1201380#M65269</link>
      <description>&lt;P&gt;Think you need to set the editor to True for versioned data:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;edit.startEditing(False, True)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Edited- grabbed the wrong description previously.&lt;/P&gt;&lt;P&gt;From the docs:&lt;/P&gt;&lt;P&gt;When False, you have full control of editing a nonversioned, or versioned dataset. If your dataset is nonversioned and you use &lt;SPAN class=""&gt;stopEditing(False)&lt;/SPAN&gt;, your edit will not be committed (otherwise, if set to True, your edits will be committed).&lt;/P&gt;&lt;P&gt;(The default value is True)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 10 Aug 2022 15:57:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/updatecursor-on-versioned-sde-data-failing/m-p/1201380#M65269</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2022-08-10T15:57:37Z</dc:date>
    </item>
    <item>
      <title>Re: UpdateCursor on versioned SDE data failing</title>
      <link>https://community.esri.com/t5/python-questions/updatecursor-on-versioned-sde-data-failing/m-p/1201390#M65270</link>
      <description>&lt;P&gt;For clarification because that doc snippet is convoluted, from their example:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;# Set multiuser_mode to False if working with unversioned enterprise gdb data
edit.startEditing(with_undo=False, multiuser_mode=True)&lt;/LI-CODE&gt;&lt;P&gt;and dont forget the closing:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;# Stop the edit operation.
edit.stopOperation()

# Stop the edit session and save the changes
edit.stopEditing(save_changes=True)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 10 Aug 2022 16:06:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/updatecursor-on-versioned-sde-data-failing/m-p/1201390#M65270</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2022-08-10T16:06:17Z</dc:date>
    </item>
    <item>
      <title>Re: UpdateCursor on versioned SDE data failing</title>
      <link>https://community.esri.com/t5/python-questions/updatecursor-on-versioned-sde-data-failing/m-p/1201396#M65271</link>
      <description>&lt;P&gt;Thank you so much! I knew it would be something small that I overlooked and just needed a fresh pair of eyes. Changing it to True worked!&amp;nbsp;&lt;/P&gt;&lt;P&gt;The false was just left over from when I was using it for my testing gdb. I did have the stopOperation and stopEditing in my script, I just forgot to include in my snippet so thank you for clarifying as well.&lt;/P&gt;</description>
      <pubDate>Wed, 10 Aug 2022 16:21:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/updatecursor-on-versioned-sde-data-failing/m-p/1201396#M65271</guid>
      <dc:creator>NicoleV</dc:creator>
      <dc:date>2022-08-10T16:21:41Z</dc:date>
    </item>
    <item>
      <title>Re: UpdateCursor on versioned SDE data failing</title>
      <link>https://community.esri.com/t5/python-questions/updatecursor-on-versioned-sde-data-failing/m-p/1237737#M66212</link>
      <description>&lt;P&gt;Any suggestion when the same error appears, despite the fact that the value of the parameter is already set to True?&lt;/P&gt;</description>
      <pubDate>Mon, 05 Dec 2022 13:23:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/updatecursor-on-versioned-sde-data-failing/m-p/1237737#M66212</guid>
      <dc:creator>Cristian_Galindo</dc:creator>
      <dc:date>2022-12-05T13:23:40Z</dc:date>
    </item>
  </channel>
</rss>

