Select to view content in your preferred language

Broken objectid... Can't InsertCursor

93
3
Wednesday
xavierlhomme
Occasional Contributor

Hello

I m writting a geopocessing tool with arcpy in order to insert some record in the enterprise geodatabase.

I'm using InsertRow from arcpy.da...

But I have an exception and the returned objectid is already in my feature table.

In order to insert the row , I need to get the max ObjectID and use an SQL statement ( Insert Into)...

It's like the sequence of objectid is broken or something like that. 

Is there any operation that can repair the ObjectID ? Or something to modify on these tables ?

Best regards 

 

Xavier Lhomme
GIS Architect / ESIRI Expert
0 Kudos
3 Replies
DanPatterson
MVP Esteemed Contributor

Have you confirmed that this is indeed the case?  Find Identical to see if it true (use the ObjectId field)

Find Identical (Data Management)—ArcGIS Pro | Documentation

and if the whole record is a duplicate, the Delete Identical to remove the record

Alternately, add a new incrementing id field and use it for the cursor


... sort of retired...
0 Kudos
HaydenWelch
Occasional Contributor

Are you using an Edit Session? If you're working on an enterprise database there might be some funky behavior involving multiuser modes. If you're directly inserting without first securing a lock on the table, there could be some funky results.

Without seeing code and such it's difficult to debug.

0 Kudos
RhettZufelt
MVP Notable Contributor

Are you trying to insert an OBJECTID?  That field is handled by the database itself and ESRI should populate the OBJECTID for you.

Have not tested, but possible that getting the max OBJECTID and incrementing it then inserting might be trying to insert your OBJECTID as well as automatically generating one, so they would/could be the same (already in table).

Also, not sure what/how you are inserting a row with arcpay.da.InsertCursor AND SQL insert into.....  Could you clarify this a bit?

R_

0 Kudos