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

SQLCODE -407 - Not Null Constraint Violation

What does SQLCODE -407 - Not Null Constraint Violation mean in RPG (IBM i / AS/400)?

An INSERT or UPDATE tried to store a NULL value into a column defined NOT NULL, usually because a host variable's null indicator was left at -1 or a required field was never populated before the statement ran.

SQLCODE -407 - Not Null Constraint ViolationDB2 for i · SQLRPGLE

Condition

An INSERT or UPDATE tried to store a NULL value into a column defined NOT NULL, usually because a host variable's null indicator was left at -1 or a required field was never populated before the statement ran.

Fix

Make sure every NOT NULL column gets a real value from the program, and check for stray null indicators being set to -1 on host variables that should never be null.

Related db2 sqlcode