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
- Check the source for duplicate values of the ON columns.
- Correct the ON condition so each target row matches only one source row.
- Reduce the source to one row per key with GROUP BY and a column function.
- Or number the source rows with ROW_NUMBER() and keep one per key.
- 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