Mainframe Path Start learning free
CoreError and abend codes-532

SQLCODE -532 — delete restricted by a relationship

Db2 refused to delete a parent row because rows in another table still point at it and the foreign key's delete rule does not allow it.

What happened

A DELETE (or a program's delete) failed. Nothing was deleted: Db2 undoes the whole statement.

SPUFI output (illustrative)Illustrative example
DSNT408I SQLCODE = -532, ERROR:  THE RELATIONSHIP ACCTCUST RESTRICTS THE
         DELETION OF ROW WITH RID X'000000020D'
DSNT418I SQLSTATE   = 23504 SQLSTATE RETURN CODE

What it means

The table you are deleting from is the parent in a referential constraint (a foreign key). At least one child row in another table still has the parent's key, and the constraint's delete rule is RESTRICT or NO ACTION, so Db2 will not leave those children pointing at nothing. The message names the relationship, which tells you which child table to look in.

A CASCADE or SET NULL rule on this relationship does not give -532 by itself, but a cascading delete that reaches a table further down whose rule is RESTRICT or NO ACTION does. Check the delete rule on every table below the parent. The rule is chosen when the foreign key is defined.

Typical causes

Where to look

How to fix

  1. Find the child rows.
  2. Decide what they should belong to. A duplicate parent usually means moving the children to the real parent with an UPDATE.
  3. Then delete the parent.
  4. Only delete children when the business confirms they are really unwanted.

Interview question

A DELETE of a customer fails with -532. What does that tell you and what do you do?

Stuck on something else?
Ask the community or search the full course.

Ask a question