RPG (IBM i / AS/400) · DB2 SQLCODE

SQLCODE -530 - Invalid Foreign Key Value

What does SQLCODE -530 - Invalid Foreign Key Value mean in RPG (IBM i / AS/400)?

An INSERT or UPDATE supplied a foreign key value that doesn't exist as a primary or unique key value in the parent table, violating a referential constraint on the table.

SQLCODE -530 - Invalid Foreign Key ValueDB2 for i · SQLRPGLE

Condition

An INSERT or UPDATE supplied a foreign key value that doesn't exist as a primary or unique key value in the parent table, violating a referential constraint on the table.

Fix

Verify the parent row exists before writing the child row, or catch this SQLCODE and prompt the user with a clear message instead of letting the exception propagate; check whether the key value is coming from stale or unvalidated input.

Related db2 sqlcode