RPG (IBM i / AS/400) · DB2 SQLCODE
What does SQLCODE -803 - Duplicate Key Value mean in RPG (IBM i / AS/400)?
An INSERT or UPDATE supplied a value that duplicates an existing value in a column enforced by a unique index, unique constraint, or primary key.
An INSERT or UPDATE supplied a value that duplicates an existing value in a column enforced by a unique index, unique constraint, or primary key.
Check for the key first (a CHAIN or SELECT) when duplicates are a normal possibility and branch to UPDATE instead of INSERT, or catch SQLCODE -803 in the program and return a friendly duplicate-key message instead of an unhandled exception.