SQL0803N SQL Origin: Data OSI layer 7 · Application Last updated 18 Nov 2026

Db2 SQL0803N: One or more values in the INSERT or UPDATE statement violate a unique index (SQLSTATE 23505)

The statement would create a duplicate value in a column or index that must be unique.

Exact message you may see SQL0803N One or more values in the INSERT statement, UPDATE statement, or foreign key update caused by a DELETE statement are not valid because the primary key, unique constraint or unique indexSQLCODE=-803, SQLSTATE=23505DB2 duplicate key SQL0803NSQLSTATE=23505 Db2
Seen on: Db2 SQL

Meaning

Find the existing row with the same key, use MERGE or check-then-update logic, fix sequence/identity values, and read which index the message names (SQLERRMC contains the constraint/index ID; look it up in syscat.indexes).

Common causes

  • Duplicate primary/unique key value
  • Identity/sequence out of sync after a load
  • Concurrent inserts of the same key
  • Retry inserting an already committed row
  • Case/whitespace-normalised duplicates

⚡ Quick fix

  1. Use MERGE INTO for upserts
  2. Identify the index in syscat.indexes
  3. Reset the identity/sequence value

Detailed fix by platform

SQL

  1. SELECT indschema, indname, colnames FROM syscat.indexes WHERE indname = 'SQL260101123456';

How to diagnose

  1. Key — Already exists?
  2. Sequence — In sync?
  3. Upsert — Needed?

🔧 Still not fixed?

Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:

Where this error sits

Origin: Data. Errors that are often confused with or caused by this one (click to open):

2627 — SQL Server: Violation of PRIMARY KEY constraint 'x'. Cannot insert duplicate key in object 'y'. (Msg 2627) (SQL)2627aggregate in WHERE — ERROR: aggregate functions are not allowed in WHERE (use HAVING) / MySQL 1111 Invalid use of group function (SQL)aggregate in WHEREcartesian — Query returns far too many rows: accidental Cartesian product (missing JOIN condition) (SQL)cartesianORA-00001 — ORA-00001: unique constraint (SCHEMA.PK_X) violated (SQL)ORA-00001SQL0204N — Db2 SQL0204N: "SCHEMA.TABLE" is an undefined name (SQLSTATE 42704) (SQL)SQL0204NSQL0911N — Db2 SQL0911N: The current transaction has been rolled back because of a deadlock or timeout (reason code 68) (SQL)SQL0911NSQLite UNIQUE failed — sqlite3.IntegrityError: UNIQUE constraint failed: users.email (SQL)SQLite UNIQUE failedSQL0803N

Explore the map of this error Full error map →

🧠 Still stuck? Analyze your error

Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.

💬 What worked for others

No tips yet — did something else fix this for you?

Share what worked for you

Tips are checked by an editor before they appear. Links are removed.