Pentaho

 View Only

 Error insert/update. Primary key duplicate

Alejandro Ramos Alvarez's profile image
Alejandro Ramos Alvarez posted 10-10-2023 10:29

Hi,

I have a job with a .ktr that insert/update registers this way:

I want to update records based on the 4 fields above. The id field is the primary key. If some of the 4 fields to be updated are different from what is in the table, do the update, otherwise do nothing. 98% of registers will do nothing. It would only be necessary to update the 4 records because they are the only ones that can change
As in the image, a duplicate primary key error appears.
Duplicate entry '27585' for key 'PRIMARY'
Can I get what I need? ?

Petr Prochazka's profile image
Petr Prochazka

Hi Alejandro,

IMHO it's not possible if table has primary key defined by only id column. So you have to add columns to primary key of table.

Or you have to check if fields are changed by another way. You can try use step Merge rows (Diff). Step compares fields via key fields. And provides result as Identical, New, Changed or Deleted.