I have issue with duplicate key

Highlighted
Six Stars

I have issue with duplicate key

This is my tmap:Capturetalend.PNG

The error message I have:

Batch entry 0 INSERT INTO "aggr". "Bench_tarifr_opecotarif" ("id", "cip13", "product", "libelle", "date_deb", "end date", "price") VALUES (0, '3400936315341', ' NICOTINELL 2MG MINT GUM S / S 96 ',' 1 to 31 January 2018 ', 20180101,20180131,10.9) was aborted: ERROR: the value of a duplicate key breaks the unique constraint "bench_tarifr_opecotarif_pkey"
   Detail: The key "(id) = (0)" already exists. Call getNextException to see other errors in the batch.
caused by: ERROR: The value of a duplicate key breaks the unique constraint "bench_tarifr_opecotarif_pkey"
   Detail: The key "(id) = (0)" already exists.

 

In the database I have a sequence for Id which is a primarykey.I already did truncate table.When I tried to insert ,I get the above error and no rows are inserted but when I do Insert/update,there is no error and just one line with Id 0 is inserted in the database table.I couldn't find the solution.If you need more details don't hesitate to contact me.


Accepted Solutions
Nine Stars

Re: I have issue with duplicate key

Tmap sequence is different then db sequence.

Use the sequence in advance col. sequence name is mentioned in table definition.

Even then if it doesnot work , reset the db seq in database.
Regards
Abhishek KUMAR

All Replies
Nine Stars

Re: I have issue with duplicate key

1) is your ID column defined as serial? if this is the case you need not pass ID column while insert

if this doesnot work

2) if you need to provide ID value use advace setting , advance column . add you ID column detail here use nextval function to get next value of sequence.

 

let me know if it solve your issue

Regards
Abhishek KUMAR
Six Stars

Re: I have issue with duplicate key

The Id  column is not serial i guess.BDD.PNGBDDtable.PNG

The advance setting ,advance column does it means that using the sequence in the  tmap .If it is like that I have already used the sequence on the tmp(you can see the screen capture in the first post).

I tried without selecting the key in the tmap,the same errors still comes when doing insert.The BDD is empty.

I did insert update ,only one line is inserting ,where the line has id 0 and It doesn't take other lines.

I don't know why.

Is there some other solutions you can propose me?

Nine Stars

Re: I have issue with duplicate key

Tmap sequence is different then db sequence.

Use the sequence in advance col. sequence name is mentioned in table definition.

Even then if it doesnot work , reset the db seq in database.
Regards
Abhishek KUMAR
Six Stars

Re: I have issue with duplicate key

Thanks akumar!

I succeeded !The problem was the key.When I deleted the key on my target on the Talend,It worked.But its strange for me because I did another execution on another table by selecting the key ,It worked out,But here it didn't work.

So I understood that when the db is declared with the key and auto-increment sequence,I  should not aliment the key .

Thanks for your help!

 

What’s New for Talend Spring ’19

Watch the recorded webinar!

Watch Now

Definitive Guide to Data Quality

Create systems and workflow to manage clean data ingestion and data transformation.

Download

Tutorial

Introduction to Talend Open Studio for Data Integration.

Watch

Downloads and Trials

Test drive Talend's enterprise products.

Downloads