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

-788

Same target row identified more than once in a MERGENEGATIVE SQLCODE · CHECKED 2026-11-07
Checked against IBM documentation

In a MERGE, one row of the target table matched several rows of the source, so it would be changed more than once and Db2 stops the statement.

QUICK ANSWER

In a MERGE, one row of the target table matched several rows of the source, so it would be changed more than once and Db2 stops the statement.

LIKELY CAUSES, IN THE ORDER OF THIS ENTRY

  1. The ON condition uses a column that is not unique in the source.
  2. The source holds duplicate keys, for example from repeated loads.
  3. The ON condition is too loose and matches more rows than intended.
  4. The source is a join that multiplies rows.

CHECKED 7 Nov 2026 IBM: Db2 13 for z/OS Codes: -788

MOST LIKELY

The ON condition uses a column that is not unique in the source.

FIRST CHECK

Check the source for duplicate values of the ON columns.

TRY IT ▸

Site search

What it means

MERGE joins the source to the target with the ON condition. If a single target row matches more than one source row, an update or delete would hit that target row several times, which Db2 does not allow, so the whole statement fails.

The message names the target table. The remedy is to make the match one-to-one, or to reduce the source to one row per target row.

Typical causes

  • The ON condition uses a column that is not unique in the source.
  • The source holds duplicate keys, for example from repeated loads.
  • The ON condition is too loose and matches more rows than intended.
  • The source is a join that multiplies rows.

How to fix it

  1. Check the source for duplicate values of the ON columns.
  2. Correct the ON condition so each target row matches only one source row.
  3. Reduce the source to one row per key with GROUP BY and a column function.
  4. Or number the source rows with ROW_NUMBER() and keep one per key.
  5. Rerun the MERGE.

Example

Illustrative only; names and values are invented.

SQLCODE = -788, SQLSTATE 21506
-- target row ID 7 matched two source rows with ID 7