0

I have the need to be able to set a value of a gdb table to the NEXTVAL of an Oracle sequence. I have to be able to do this through an ArcPy function that will also handle setting the ArcPy OBJECTID in the table (such as InsertCursor will automatically increment that field).

I have tried the following with no luck:

my_insert = arcpy.InsertCursor(My_SDE_Table_Path)
new_record = my_insert.newRow()

new_record.setValue('SEQUENCED_ID', 'MYSEQUENCE.NEXTVAL')

my_insert.insertRow(new_record)

This just attempts to write the string "MYSEQUENCE.NEXTVAL" to that field.

Anybody know of a solution to use sequences with ArcPy? I've scoured the Esri documentation but it's like a labyrinth.

  • This is only an aside, but what version of ArcGIS for Desktop are you using? I ask because your code is using the old, very slow, style of ArcPy cursor. If you use arcpy.da.InsertCursor() instead of arcpy.InsertCursor() then your code will run much faster. The arcpy.da module became available at 10.1. – PolyGeo Nov 18 '15 at 22:17
  • 10.3 And that's the Insert Cursor an Esri rep pointed me to a few weeks back. – disflux Nov 19 '15 at 0:42
  • If you only need to access one row in total then cursor speed would not be a factor. That's the only reason that springs to mind for why to use the old style, besides its syntax being easier for someone new to Python. – PolyGeo Nov 19 '15 at 1:27

Your Answer

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

Browse other questions tagged or ask your own question.