While MERGE is executing, the same row in the target table cannot be updated more than once. Inserted rows are not updated by the MERGE statement. Using the previous example, if the sale table contains the two records shown at the left, then the new_sale table contains the three records shown at the right:
Records in 'sales' Table | Records in 'new_sales' Table | |||
---|---|---|---|---|
cust_id | sale_count | cust_id | sale_count | |
Tom | 129 | Tom | 20 | |
Julie | 230 | Julie | 3 | |
Julie | 10 |
When merging new_sale into sale using the expression sale.cust_id = new_sale.cust_id, the MERGE statement returns an error, because it attempts to update one of the records in the source table more than once.