Question

How do I update a date attribute in a Non-Spatial SQL server table using a date from another SQL table?

  • 6 March 2019
  • 1 reply
  • 7 views

Badge

We use Cityworks and ESRI softwares for asset management. I am trying to update a date field in the cityworks table using a value from the ESRI SDE table. I get this error: Microsoft SQL Server Non-Spatial Writer: Failed to write a feature of type `azteca.WORKORDERENTITY' to the database. Provider error `(-2147217873) Violation of PRIMARY KEY constraint 'CW_PKEY_521'. Cannot insert duplicate key in object 'azteca.WORKORDERENTITY'. The duplicate key value is (510833).'. SQL Command `UPDATE azteca.[WORKORDERENTITY] SET [ENTITYUID]=?, [OBJECTID]=?, [WARRANTYDATE]=? WHERE [ENTITYUID]=?'

This is my workspace:

Sorter sorts FacilityID descending. Attribute renamer renames warrantydate to newdate. FeatureMerger joins on entityuid and facilityid. This worked in older versions of FME, Cityworks and SQL. I'm not sure what changed. I've tried different things and continue to get basically the same error stating that it cannot insert a duplicate record. I tried inserting an fme_db_operation - update after the FeatureMerger and got the same thing.


1 reply

Userlevel 4

If you look at the definition of the constraint 'CW_PKEY_521', which attribute(s) does it reference? E.g. OBJECTID or ENTITYUID?

Is it possible that the primary key already exists and you are updating multiple rows with the same combination, resulting in a duplicate primary key?

Reply