Cannot insert duplicate key in object

I have a record type with following releation Request Master (one to one) Payment Request (One to One) Invoice Header (One to One) Invoice Payment Info but getting following error

Unable to write to or delete from the source due to a data integrity violation.
Error Details: Violation of UNIQUE KEY constraint 'UQ_PAYMENT_INFO_HEADER_INVOICE_ID'. Cannot insert duplicate key in object 'dbo.INVOICE_PAYMENT_INFO'. The duplicate key value is (21769).

Not sure why its throwing duplicate key as the ID PK attribute is blank

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Lead Developer

    Appian is attempting to INSERT a new row into INVOICE_PAYMENT_INFO instead of UPDATE the existing one — because the PK of INVOICE_PAYMENT_INFO is null during the write operation.

    The constraint UQ_PAYMENT_INFO_HEADER_INVOICE_ID is on INVOICE_ID — not the PK. So even though PK is blank, the duplicate is caught on INVOICE_ID = 21769 which already exists.

Reply
  • 0
    Certified Lead Developer

    Appian is attempting to INSERT a new row into INVOICE_PAYMENT_INFO instead of UPDATE the existing one — because the PK of INVOICE_PAYMENT_INFO is null during the write operation.

    The constraint UQ_PAYMENT_INFO_HEADER_INVOICE_ID is on INVOICE_ID — not the PK. So even though PK is blank, the duplicate is caught on INVOICE_ID = 21769 which already exists.

Children
No Data