Learn it on Mainframe Path. Do it with Mainframe KIT.Learn on Mainframe Path ▸
Mainframe KIT ● Nothing leaves this tab

-803

Duplicate values would violate a unique indexNEGATIVE SQLCODE · CHECKED 2026-11-14
Checked against IBM documentation

An insert or update would create duplicate values in columns that a unique index, primary key, unique constraint or hash key requires to be unique.

QUICK ANSWER

An insert or update would create duplicate values in columns that a unique index, primary key, unique constraint or hash key requires to be unique.

LIKELY CAUSES, IN THE ORDER OF THIS ENTRY

  1. An INSERT supplies a key value that already exists in the table.
  2. An UPDATE changes columns so that they match another row's unique key.
  3. The INSERT's subquery returns rows that duplicate existing keys.
  4. A cascading delete sets a foreign key to NULL in a dependent row, producing duplicate values.
  5. A MERGE collides with the object table's uniqueness constraint, rarely because of another concurrent INSERT or UPDATE.

CHECKED 14 Nov 2026 IBM: Db2 13 for z/OS: SQLCODE -803 (Db2 for z/OS 13.0.0)

TRY IT: BLOCK SIZE AND SPACE CALCULATOR ▸

MOST LIKELY

An INSERT supplies a key value that already exists in the table.

FIRST CHECK

Find the uniqueness rule from SYSIBM.SYSINDEXES using the index space name in the message.

TRY IT ▸

Block size and space calculator

What it means

The table is constrained to have unique values in certain columns, and completing the operation would produce duplicates. The message names the index space and the record ID of the existing row. SQLSTATE is 23505.

The constraint can be a primary key, unique constraint, unique index, or a hash key on a hash-organized table. For an XML index, duplicates can come from the XML values or from data type conversion and rounding.

Typical causes

  • An INSERT supplies a key value that already exists in the table.
  • An UPDATE changes columns so that they match another row's unique key.
  • The INSERT's subquery returns rows that duplicate existing keys.
  • A cascading delete sets a foreign key to NULL in a dependent row, producing duplicate values.
  • A MERGE collides with the object table's uniqueness constraint, rarely because of another concurrent INSERT or UPDATE.

How to fix it

  1. Find the uniqueness rule from SYSIBM.SYSINDEXES using the index space name in the message.
  2. For an insert, examine the object table for the values that violate the constraint.
  3. For an insert with a subquery, compare the subquery results with the object table.
  4. For a cascading delete, check the index key columns of the dependent table for foreign keys set to NULL.
  5. For a MERGE that fails rarely, handle concurrency (for example change the isolation level or rerun the statement).