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

SQLCODE -803 - Duplicate Key Value

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.

SQLCODE -803 - Duplicate Key ValueDB2 for i · SQLRPGLE

Condition

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.

Fix

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.

Related db2 sqlcode