Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Click here for Video Transcript
Note: The concept ’ UPSERT MODE’ and 'MERGE MODE' is not documented in the User Guide. i.e. it is not a word you can search for in the User Guide and is not a key word in the Replicate UI.
UPSERT MODE: Change an update to an insert if the row doesn't exists on the target
MERGE MODE: Change an insert to an update if the row already exists on the target
Use MERGE MODE: i.e. configure the task under: task setting --> Error Handling --> Apply Conflicts --> ‘Duplicate key when applying INSERT:’ UPDATE the existing target record
Use UPSERT MODE: i.e. configure the task under: task setting --> Error Handling --> Apply Conflicts --> ‘No record found for applying an UPDATE:’ INSERT the missing target record
Batch Apply and Transactional Apply modes:
There is a big difference in how these Upsert/Merge settings work depending of whether the task is in 'Batch' or 'Transactional' Apply mode.
Batch Apply mode:
Either option (Upsert/Merge) does an unconditional Delete of all rows in the batch, followed by an Insert of all rows.
Note: The other thing to note is that with this setting the actual update that fails is inserted in a way that may not be obvious and could cause issue with downstream processing. In batch apply mode the task will actually issue a pair of transactions (1st a delete of the record and then 2nd an insert) this pair of transactions is unconditional and will result in a "newly inserted row every time the record is updated on the source.
Transactional Apply mode:
Either option (Upsert/Merge) - the original statement is run and if it errors out then the switch is done (try and catch).
Insert in transactional apply mode, the insert statement will be performed in a "try / catch" fashion. The insert statement will be run and only if it fails will it be switched to an update statement .
In transactional apply mode, the update will be performed in a "try / catch" fashion. The update will be run and only if it fails will it be switched to an insert statement .
The information in this article is provided as-is and to be used at own discretion. Depending on tool(s) used, customization(s), and/or other factors ongoing support on the solution below may not be provided by Qlik Support.
Will it work without CDC ? i am trying but not working without CDC, kindly suggest me if you know any there ways to resolved this
Hi @jamshed ,
This process is designed for Change Data Capture (CDC) only. It does not apply during the Full Load phase.
For the initial load, there are four options available:
If the initial load is interrupted and the task stops before completion, the next run will restart the entire initial load from the beginning.
Regards,
John.
Hi @john_wang
We are encountering an issue where an UPDATE operation is attempting to modify the Primary Key to a value that already exists in the target, resulting in the following error:
The 'UPDATE' for table 42 at stream position '00E26D692AB1C01BAA000001' changes PK to a PK already in use
Note: In Task Settings → Change Processing → Change Processing Tuning, we have enabled SQL MERGE.
Could you please help clarify:
Thanks,
Shyam Sundar.
Hello Shyam Sundar, @shyamkatika
Would you mind sharing the source and target endpoint types?
thanks,
John.
Hi @john_wang
Hi John,
The source endpoint is IBM Db2 for z/OS, and the target endpoint is Snowflake on Azure.
Thanks,
Shyam Sundar.
Hello Shyam Sundar, @shyamkatika
I tested multiple scenarios in my lab, but was unable to reproduce the behavior.
In general, for a standard UPDATE, Qlik Replicate generates a MERGE INTO statement. However, if the UPDATE modifies primary key values, Qlik Replicate will not use MERGE INTO; instead, it will apply the change as a DELETE + INSERT pair for that row.
To better understand the issue, I recommend opening a support ticket and providing the following information:
Regards,
John.
Hi @john_wang
Thank you for the update.
We are currently using Qlik Replicate with Snowflake as the target endpoint, running on version 2025.05.
1. Although the recommendation is to use DELETE + INSERT instead of UPDATE for PK changes, this option is currently showing as inactive in our setup. Could you please help clarify why this option is disabled and how it can be enabled?
2. If we deselect the “Apply SQL MERGE” option, will updates (including primary key updates) be applied correctly without causing conflicts on the target? In other words, will this approach help avoid the PK conflict issue we are currently facing?
Appreciate your guidance on this.
Regards,
Shyam Sundar.
Hello Shyam Sundar, @shyamkatika ,
Regards,
John.