AnsweredAssumed Answered

Transaction mode problem

Question asked by craygo on May 18, 2016
Latest reply on May 19, 2016 by craygo

I know this has been asked, and I have tried all suggestion I could find. Maybe I am missing something. Here is my code

# ------------------------------------------------------------------------------
# Cstar_Update.py
# Created on: 2012-06-05 12:56:35.00000
# Updated 05/18/2016 by: Raymond Goins
#   
# Description:
# Updates Stop number in Customer Star database from selected feature in ArcMap
# ------------------------------------------------------------------------------

# Import arcpy module
import arcpy

# Local variables:
# table = r"C:\PWSB GIS\GIS Scripts\conn\CStar.odc\SVC_LOC"
table = r"C:\PWSB GIS\GIS Scripts\conn\PWMedia.odc\CSTARTMP"

# Set variable to see if a feature is selected
sel = len(arcpy.Describe("WATER.SERVICELOCATION").FIDSet)

if sel >= 1:
    with arcpy.da.SearchCursor("WATER.ServiceLocation", ['STOP_NUMBER', 'SVC_LOC_NB']) as wslrow:
        # Loop through selected features
        for row in wslrow:
            stopnumber = row[0]
            svcloc = row[1]
            # Make sure SVCLOC number is not null
            if svcloc is not None:
                # Check to see if SrvLoc number exists
                rcheck = arcpy.da.SearchCursor(table, ['*'], "SLOC_SVC_LOC_NBR = " + "'" + str(svcloc) + "'")
                i = 0            
                for r in rcheck:
                    i += 1
                del r
                del rcheck
                # If exists loop through
                if i > 0:
                    csrows = arcpy.da.UpdateCursor(table, ['SLOC_STOP_NUMBER'], "SLOC_SVC_LOC_NBR = '" + str(svcloc) + "'")
                    for csrow in csrows:
                        arcpy.AddMessage("ServiceLoc " + str(svcloc) + " found")
                        csrow.SLOC_STOP_NUMBER = stopnumber
                        csrows.updateRow(csrow)
                        arcpy.AddMessage("Stop number updated to " + str(stopnumber))
                    del csrows
                    del csrow                    
                else:
                    arcpy.AddMessage("Service Loc not found in CStar. Could not update Stop Number.")
                del i
                del svcloc
                del stopnumber
            else:
                arcpy.AddMessage("Service Loc Not Set in GIS.")
            del row
    del wslrow
else:
    arcpy.AddMessage("Please select a service Location.")
del sel

It works the first time but the get the workspace already in transaction mode error. I use this while in the same edit session. I basically click a feature update the field then push it into another database. Both databases use ORACLE but are on different servers.

 

Thanks for taking a look

 

Ray

Outcomes