Thanks for the tip. I will look into it. One thing I should have mentioned is only the SERVICELOCATION table is a feature layer. The odc connection is just an oracle table in another database. The reason I wanted the checks in there is in case the GIS editor puts the wrong SVCLOC number in the GIS table I want to make sure it exists in the SVC_LOC table.
I have been going through the code and found this works fine.
# ------------------------------------------------------------------------------
# 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:
wslrow = arcpy.da.SearchCursor("WATER.ServiceLocation", ['STOP_NUMBER', 'SVC_LOC_NB'])
# 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 make sure Stop number is not null
if stopnumber is not None:
# Check to see if SrvLoc number exists
rcheck = arcpy.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.UpdateCursor(table, "SLOC_SVC_LOC_NBR = '" + str(svcloc) + "'")
for csrow in csrows:
arcpy.AddMessage("ServiceLoc " + str(svcloc) + " found")
csrow.setValue("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
else:
arcpy.AddMessage("Stop Number Not Set in GIS.")
else:
arcpy.AddMessage("Service Loc Not Set in GIS.")
del svcloc
del stopnumber
del row
del wslrow
else:
arcpy.AddMessage("Please select a service Location.")
del sel
Seems the arcpy.da function is causing the problem. I also removed "with" and went to deleting the objects manually.
All seems to work fine so far
Thanks again for the help and tips
Ray