AnsweredAssumed Answered

Automated Rebuilding of Network Datasets - Oracle 11g SDE

Question asked by duncan.fetner_Zayo on Dec 2, 2017
Latest reply on Jun 16, 2018 by duncan.fetner_Zayo

I'm working on some Python scripts to automate the rebuilding of a couple of different network datasets based on new data coming in from our SDE. To ensure I wouldn't experience any SDE related issues (not really a database guy), I set up the network datasets in a FGDB. However, I'm experiencing some performance issues have decided to try to move the NDs to a feature dataset in SDE. This is where my issues have started coming up.


Since creating NDs isn't possible via ArcPy without getting into areas waaaay outside my skill level, I've got my scripts creating new edge and junction feature classes in memory, removing all rows in the participating ND feature classes, inserting the new features from memory into the empty participating feature classes, and rebuilding the existing ND. I created a new ND in our SDE, and attempted to run my first test, but hit issues when I began my update cursor to delete the participating features. Got the ol Workspace is Already in Transaction Mode error. I tried to register the feature dataset as versioned to see if that would help things, but since SDE NDs don't allow for versioning of feature classes that already participate in NDs, I couldn't. I'm at a loss here. Here's a code sample (sorry that it's an image, can't get code formatted to look right otherwise):


existingJunctions = r"pathtoSDEFeatureDataset\Junctions"
existingEdges = r"pathtoSDEFeatureDataset\Edges"
networkDataset = r"pathtoSDEFeatureDataset\NetworkDataset_ND"

edit = arcpy.da.Editor(r"path to SDE Database")
#tried all parameter combinations before settling on False False
edit.startEditing(False, False)

#delete all rows from existing ND junctions
with arcpy.da.UpdateCursor(existingJunctions, "*") as uCur:
for row in uCur:

#insert updated junctions from memory into participating junctions fc
with arcpy.da.SearchCursor(junctions, "*") as sCur:
with arcpy.da.InsertCursor(existingJunctions, "*") as iCur:
for row in sCur:

#delete all rows from existing ND edges
with arcpy.da.UpdateCursor(existingEdges, "*") as uCur:
for row in uCur:

#insert updated edges from memory into participating edges fc
edgeFields = [ for f in arcpy.ListFields(existingEdges) if != "SHAPE_Length"]
edgeFields.insert(0, "SHAPE@")
with arcpy.da.SearchCursor(fiber, fiberFields) as sCur:
with arcpy.da.InsertCursor(existingFiber, fiberFields) as iCur:
for row in sCur:


#end edit session


If there is a suggestion on how to get this code working OR another idea on how to handle regular updates of network datasets without manual creation of new NDs, please let me know. Any help is tremendously appreciated!!