Select to view content in your preferred language

ArcSDE FeatureClass update with edit session problems

4004
7
11-05-2013 05:23 PM
JoeHewitt
Regular Contributor
Hello,

I am trying to run an update on an ArcSDE FeatureClass using ArcPy.
With the goal of my code starting an edit session, making a change to my FC and then saving the changes, so this change will show up in the (date_Changed) attribute like ArcSDE is supposed to. This is my code below: (Just an example of trying to use the insertcursor, normally I would try to deletefeatures then append, but I figured start small first)




import arcpy
from arcpy import env
arcpy.MakeFeatureLayer_management(r'Database Connections\GISAdmin@SBMPERDBS003.sde\GISAdmin.Leonora_Drilling\GISAdmin.LEO_DH_Collars','LeoDHCollars')
arcpy.MakeXYEventLayer_management(r'\\SBMPERTST001\Applications\GIS\DataShed Exploration_LEO Export\Arc_DHCollars.csv',"NAT_East","NAT_North","LeoDHCollarsNEW")
arcpy.MakeFeatureLayer_management("LeoDHCollarsNEW",'LeoDHCollarslyr')
arcpy.ChangeVersion_management('LeoDHCollars','Transactional','GISADMIN.DataUpdates','')
workspace=r'Database Connections\GISAdmin@SBMPERDBS003.sde'
edit= arcpy.da.Editor(r'Database Connections\GISAdmin@SBMPERDBS003.sde')
edit.startEditing(True,True)
edit.startOperation()
with arcpy.da.InsertCursor("LeoDHCollars", ('SHAPE@', 'Hole_Type')) as icur:
    icur.insertRow([(7642471.100, 686465.725), 'New School'])
edit.stopOperation()
edit.stopEditing(True)
arcpy.DisconnectUser(r'Database Connections\SDE@SBMPERDBS003.sde', "ALL")
arcpy.ReconcileVersions_management(workspace,"ALL_VERSIONS","SDE.GIS_Default","GISADMIN.DataUpdates","LOCK_ACQUIRED","NO_ABORT","BY_OBJECT","FAVOR_TARGET_VERSION","POST","KEEP_VERSION")








The problem I am getting is RunTime Error: Workspace already in transaction mode.

Any thoughts of why?
Tags (2)
0 Kudos
7 Replies
MattSayler
Frequent Contributor
Is your data versioned?
0 Kudos
MattSayler
Frequent Contributor
Try setting the workspace first thing. Also should it be "env.workspace = r'Database Connections\GISAdmin@SBMPERDBS003.sde'"? And on line 15 it switches from 'Database Connections\GISAdmin@SBMPERDBS003.sde' to 'Database Connections\SDE@SBMPERDBS003.sde'

Not super confident any of those are causing the error, but easy enough to try.
0 Kudos
PaulSchneider
Regular Contributor
I believe you are getting this error because the dataset is not registered as versioned with the database?

Try changing to:

...
edit.startEditing(True,False)
...


or register the dataset as versioned before opening the edit session
0 Kudos
WilliamCraft
MVP Regular Contributor
And on line 15 it switches from 'Database Connections\GISAdmin@SBMPERDBS003.sde' to 'Database Connections\SDE@SBMPERDBS003.sde'


The "Database Connections" part of the path that you are seeing is normal behavior.  This is Esri's way to abbreviating the default location where SDE connection files are stored on the machine when creating them under Database Connections in ArcCatalog or ArcMap.  So, "Database Connections\..." really refers to the user profile directory.  For example in Windows 7 or Windows Server 2008 R2,

C:\Users\userID\AppData\Roaming\ESRI\ArcCatalog\SDE@SBMPERDBS003.sde

...would be represented by Esri software as...

Database Connections\SDE@SBMPERDBS003.sde
0 Kudos
MathewCoyle
Honored Contributor
My solution was to create a version then create a database connection file and reference the newly created version as the default. I could then drop the change version operation as the edit opens with the specified version from the connection file.
0 Kudos
pfoppe
by MVP
MVP

Esri has confirmed this situation and marked it as a bug: 

 

 

BUG-000114598:
-----------------------------
RuntimeError "workspace already in transaction mode" occurs when using da.UpdateCursor on TableView after changing the version.

0 Kudos
MattSayler
Frequent Contributor
The "Database Connections" part of the path that you are seeing is normal behavior.  This is Esri's way to abbreviating the default location where SDE connection files are stored on the machine when creating them under Database Connections in ArcCatalog or ArcMap.  So, "Database Connections\..." really refers to the user profile directory.  For example in Windows 7 or Windows Server 2008 R2,

C:\Users\userID\AppData\Roaming\ESRI\ArcCatalog\SDE@SBMPERDBS003.sde

...would be represented by Esri software as...

Database Connections\SDE@SBMPERDBS003.sde


I was refering to the switch in user from GISAdmin to SDE.
0 Kudos