I have connected my ArcMap to my PostgreSQL db using the Create Enterprise Geodatabase tool in ArcMap. I have multiple feature classes and the relevant relationships between them loaded into the db correctly.

However, I am attempting to add a unique sequence to the feature classes using the postgres sequence function as below:

CREATE SEQUENCE my_sequence;

I then set the default for an integer colum in my tables and assign the sequence as below:

SET DEFAULT nextval('my_sequence');

However, the sequencer works perfectly if I insert data inside PostgreSQL using a SQL statement. If I edit the same table in ArcMap I get the following error when trying to save my edits:

ERROR: duplicate key value violates unique constraint
DETAIL: Key(uniq_id)=(0)already exists

Where am I overlooking something?

  • 1
    Did you enable Archiving or Versioning on that table by any chance?
    – Berend
    Aug 21 '18 at 7:04
  • I have tried this these approaches, although it lets me save the edits it still populates each new row with a sequence number of 0.
    – WhaleShark
    Aug 21 '18 at 7:08
  • It seems that apart from the default value, there is also a unique index on the field, is that correct? I think ArcGIS doesn't like those on versioned or archived featureclasses. (because duplicate values can exist in the _H or _A tables)
    – Berend
    Aug 21 '18 at 7:15
  • Edits on versioned feature classes do not fire actions on the base table until after posting. Please Edit the question to contain more details on your exact procedure.
    – Vince
    Aug 21 '18 at 11:07
  • It's possible the object id that is typically used and then sequencer are both set to unique keys somehow for SDE. I would double check in pg-admin what the configurations are for the fields. Typically a sequential object is a unique key, and object id is that for Arc Desktop.
    – enolan
    Aug 21 '18 at 20:28

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.