0

We are running a script that creates data in one of the ClaimCenter tables. This table has a foreign key reference to contacts table, that we do not use.

We get an exception:

org.h2.jdbc.JdbcBatchUpdateException: Referential integrity constraint violation: CONSTRAINT_C7F2: PUBLIC.CCX_CLAIMCONTACTEMAILATTACHMENT_EXT FOREIGN KEY(CLAIMCONTACTID) REFERENCES PUBLIC.CC_CLAIMCONTACT(ID) SQLSTATE = 23506
SQL error code = 23506

Is there a way to create entries in CLAIMCONTACTEMAILATTACHMENT_EXT without creating on CC_CLAIMCONTACT or breaking this referential integrity and making it work?

We want to create records in CLAIMCONTACTEMAILATTACHMENT_EXT without creating on CC_CLAIMCONTACT.

eglease
  • 2,445
  • 11
  • 18
  • 28
Wen
  • 1
  • 1

2 Answers2

1

I am assuming the following from your question:

  • ClaimContact has a 1 to N relationship with your custom ClaimContactEmailAttachment_Ext entity. This would mean that ClaimContact has an array of ClaimContactEmailAttachment_Ext defined in the ClaimContact.etx file and ClaimContactEmailAttachment_Ext has a foreignkey defined in the ClaimContactEmailAttachment_Ext.eti file
  • The new ClaimContactEmailAttachment_Ext entity is supposed to only be associated to a ClaimContact entity. The naming of the ClaimContactEmailAttachment_Ext seems to suggest this

If the 2 assumptions above are true then I think you should just modify your script to add the appropriate ClaimContact entities to the Claim in the same bundle that you are adding your ClaimContactEmailAttachment_Ext entities.

If, however, ClaimContactEmailAttachment_Ext is meant to be more of a admin type of data that can be used across multiple claims, then I would probably rename this entity to something more appropriate. If this is meant to be an admin data type, then there should not be a foreign key from this entity to a claim-level entity. The foreign key should be defined on the claim-level entity.

0

Are you using a gosu script or a DB script? Generally, it's not a good idea to break the constraints and can cause DB consistency issues.

Arjun
  • 108
  • 9
  • We are using a Gosu script. Tried options of onetoone key. Not sure if there are other options. – Wen Jul 31 '23 at 18:55
  • 1
    Ok, there is no way to insert the data without having a reference to the claimcontact. If you intend to treat it as global data irrelevant to contact, then there should be no FK reference in the data model design – Arjun Aug 01 '23 at 18:33
  • https://stackoverflow.com/help/someone-answers – Arjun Aug 02 '23 at 18:38