Error Executing Query - Clear Data Query

Error Executing Query - Clear Data Query

  

Running "Test" from the SQL Query maker below

Generates this Error Code


All I am trying to do is delete test data from the Employee Table by using the DELETE FROM statement.

Here's another error code I am getting when I remove OnlineTraining Table from the query above.

Solution

Hello Jared

Do you remember the training? About Foreign Keys?

If a FK delete rule is set to protected, you can't delete the records in the parent entity when there are records pointing to them.

Solution:

1. Change delete rule in the FK to Delete or Ignore (what is best for you...).

2. Delete FIRST the records in the child entity (the one with the FK) and only after the parent entity.

Cheers

Solution

I did this once before, but when I've been creating new tables, I forgot to take off protect from the new keys. Thanks, Eduardo.

Jared Davis wrote:

I did this once before, but when I've been creating new tables, I forgot to take off protect from the new keys. Thanks, Eduardo.

Just remember that the "ignore" is problematic, as it does not preserve database integrity, so, if you are using ignore, be careful.

Cheers.