constraint error
When I go to delete a record this exception appears, but the exclusion rule in the LogStatusSistemaMailing table in the ContestacaoId field is like delete, try to change it to ignore but the error persists

Does anyone know how I can fix this problem?
Capturar.PNG

Hi Gabriel,

The error message itself showing there is a foreign key constraint error, which means you are deleting a parent table where the child table contains the Primary table identifier as a foreign key. To avoid this error, you need to delete child table records first and after that the parent table record.

Refer below posts for more info-

https://www.sqlshack.com/commonly-used-sql-server-constraints-foreign-key-check-default/

https://dba.stackexchange.com/questions/153420/mysql-delete-row-that-has-a-foreign-key-constraint-which-reference-to-itself

https://stackoverflow.com/questions/43493889/cannot-delete-or-update-a-parent-row-a-foreign-key-constraint-fails-mysql/43494234

https://blog.dbi-services.com/mysql-foreign-keys-and-cannot-delete-or-update-a-parent-row-a-foreign-key-constraint-fails-error/

Thanks, Aadhavan S


But FK alrready has the DELETE rule and even so the error continues

Hi Gabriel,

consider the chance of the record with the FK to have also FKs on another tables. You need to dig down all the chain of FKs to understand the cause.

Changing to ignore should solve quicker.

Regards


This is very strange, since all FKs in the Contestacao table have the Delete or Ignore rule

Hello @Gabriel Thiengo 

My understanding from the error message is that you should be checking the Foreign Key settings for e.g. for ContestacaoID in the LogStatusSistemaMailing table (not the Contestacao table). Or maybe I misunderstood your post above, but please look at my other post on this thread and it would be great if you could share a screenshot of the Delete Rule(s).

Thanks,

AJ

Hello @Gabriel Thiengo,

Please confirm that you are trying to delete from the CONTESTACAO table but the FK - ContestacaoID in the LogStatusSistemaMailing is causing an issue. 

Could you please share a screenshot of the LogStatusSistemaMailing with the ContestacaoID attribute selected, displaying the Delete Rule for e.g. as shown in the sample screenshot below:

Regards,

AJ


Champion

Hi Gabriel,
Despite all the answers above; would suggest a quick fix:

  • Make sure the Delete Rule on the FK attribute on  that Entity is set to DELETE; Publish
  • And then Refresh the consumer module's of that Entity
  • Test

- Assif

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.