1

I am new to ArcGIS and arcpy and am learning largely through trial and error. Anyway, the overall task is to delete, edit and add rows to feature classes.

I thought it would be good to start with delete - it seemed the simplest. In the desktop I can change to a version, start an editing session and delete the object. However, when I try the script below, it fails with a database error. On the desktop I don't seem to be able to delete unless I do 'Start Editing', but I can't find that in arcpy for 10.0. I see over the years other posts but nothing quite like this. Is this something that I should be able to do with arcpy?

arcpy.env.workspace = myconnect
versions = arcpy.ListVersions()
versionName = "montgs1"
layer='layer'

arcpy.MakeFeatureLayer_management("ARCFM.DistributionMain", "layer")
arcpy.ChangeVersion_management(layer, 'TRANSACTIONAL', user + "."+versionName,'')

qry ='"OBJECTID" in (3142049,4228649)'

arcpy.SelectLayerByAttribute_management(layer, "NEW_SELECTION", qry)

numsel =int(arcpy.GetCount_management(layer).getOutput(0))
if numsel > 0:
    print str(numsel) + ' features selected'
    arcpy.DeleteFeatures_management(layer)

Incidentally, when I use that criteria in the gui, it selects two items, however in the script numsel's value is 1.

Anyway, when the delete happens I get this:

(, ExecuteError('ERROR 999999: Error executing function.\nUnable to create logfile system tables. User perhaps lacks permissions or resources to create tables\nUnderlying DBMS error [ORA-01455: converting column overflows integer datatype\n] [ARCFM.DistributionMain]\nFailed to execute (DeleteFeatures).\n',), )

Why does it work on the GUI but not with arcpy?

  • 1
    Start editing is in arcpy.editor, your error message is a UAC or permissions problem.. is your database Oracle? if so you need to speak to your DB admin folk as view, insert, update, delete permissions to that database type need to be granted separately. Of course it could be that your database does not allow deletes out of an edit session to protect the database, does this tool work in ArcCatalog? – Michael Stimson May 11 '16 at 2:34
  • 1
    Can you do a large selection of ARCFM.DistributionMain features in ArcMap? The error reminds me of something we used to get quite regularly in Oracle. Our DBAs didn't allow users create table permission but in order to store selections and edits ArcMap needs to create users own logfiles. The solution was to temporarily grant create table to a new user, login and do a large selection, which caused ArcMap to create the log tables, then the DBA would revoke create table once the logfile tables had been created. – Dowlers May 11 '16 at 4:04
  • Thanks @MichaelMiles-Stimson, I think that might be the key thing. I'll look at ArcCatalog, but in ArcGis I couldn't find an obvious way to delete a feature until I started an editing session. I know in the arcpy.da package you can do start editing - but the data access package started with 10.1. I've looked for arcpy.editor online but haven't found much yet. I'll try later and see if I manage a breakthrough. – Bryan May 11 '16 at 10:27
  • One thing you need to be aware of, SDE is special when it comes to modify/delete features... if your database is versioned all edits must be done in an edit session, bracketed by an edit operation. This is also true of features that participate in a network or topology, versioned or not. If there's not arcpy.da.editor in v10 either upgrade your desktop to 10.1 (at least) or do this in ArcObjects - note that any version of desktop can connect to a previous (or same, but not more recent) version of SDE so you don't need to upgrade your SDE database concurrently. – Michael Stimson May 11 '16 at 22:46
1

So, I was working in both the ArcGis GUI and arcpy scripting and accidentally found somewhat of a hacky solution.

I tried creating sessions and was looking to execute the script from within the GUI's python window. In experimenting there, I found that the session appeared in the same list as versions when connecting to the Oracle DB. So, if I connect to a 'session' when connecting to the DBMS, as opposed to changing to a version, I can delete records. I did confirm that if I tried connecting to the version when I made the database connection that it still failed.

I'm working on getting a newer client - in the meantime, the script will need to be invoked with a session that the db user has access to. Should be good enough to prove a couple of points.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.