Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us in Toronto Sept 9th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Manoj_MUTHURAJA
Creator
Creator

I have issue with duplicate key

This is my tmap:0683p000009M2E3.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.

Labels (2)
1 Solution

Accepted Solutions
akumar2301
Specialist II
Specialist II

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.

View solution in original post

4 Replies
akumar2301
Specialist II
Specialist II

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

Manoj_MUTHURAJA
Creator
Creator
Author

The Id  column is not serial i guess.0683p000009M2A2.png0683p000009M1re.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?

akumar2301
Specialist II
Specialist II

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.
Manoj_MUTHURAJA
Creator
Creator
Author

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!