Check for Duplicate UPDATE Statements
The Hyper-Q hint update_duplicate_check lets you check for duplicate records in UPDATE statements.
The syntax for update_duplicate_check is:
update_duplicate_check = none | M1 | M2
where:
Parameter | Description |
|---|---|
| Turns off duplicate checking. |
| Specifies that:
|
| Specifies that a when using UPDATE with a non-equality predicate between the target and the source tables, that a LEFT [ OUTER ] JOIN perform the duplicate check. |
Hint Scope
The update_duplicate_check hint can be specified at the request, session, and global level. To learn more about Hyper-Q SQL hints, and how to use them within a SQL query, see About Hyper-Q SQL Hints.
You can specify update_duplicate_check as a global setting in the Hyper-Q configuration file (dtm.ini). In the example shown below, update_duplicate_check is enabled using the M1 setting.
"gateway".update_duplicate_check = M1
To learn more about specifying a hint as a gateway option in the Hyper-Q configuration file, see Gateway Configuration Parameters.
In the following example table_1 is the target table, and table_2 and table_3 are the source tables for the UPDATE. A non-equality predicate between the target and the source tables specifies which rows are to be modified, and update_duplicate_check uses a LEFT [ OUTER ] JOIN to perform the duplicate check using the M2 option.
When using update_duplicate_check as a query hint, you must specify if it is to be applied at the request or session level. This example specifies that it be applied at the request level using the for request specifier.
UPDATE table_1 FROM tgt table_1, src table_2, src table_3 SET j=table_2.j --@dtm_update_duplicate_check=M2 for request WHERE table_1.i<table_2.i OR table_1.i + 10 > table_3.i;
To learn more about Hyper-Q SQL hints, and how to use them within a SQL query, see About Hyper-Q SQL Hints.
In the following example table_1 is the target table, and table_2 is the source table for the update. This example specifies that the update_duplicate_check hint be applied at the session level using the for session specifier.
UPDATE table_1 FROM database_name.CUSTOMER_BILL table_1, database_name.SALES table_2 --@dtm_update_duplicate_check=M2 for session SET AC_ID=5 WHERE table_1.SSID=5 AND table_2.SSID=5 AND ( NVL(table_2.ATTRIBUTE20,'')<>'FFS' OR table_2.SALES_SKEY=5 OR table_2.AC_ID=5 ) AND DECODE(table_1.ORG_ID,NULL,cast(5 as numeric(18,0)),table_1.SALES_SKEY) = table_2.SALES_SKEY AND 5 = 5;