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

Announcements
Write Table now available in Qlik Cloud Analytics: Read Blog
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

how to fetch primary keys from db and set it to tmap entries

Hi,
I have a requirement where I have a set of excel files, I need to either create or update the entries in db. The creation part has been done. So if the run the job again it should update those entries. I searched in talend forum and i got an option for tmysqloutput as "update or insert".
First is this approach correct?
If so for update requires the primary key from db. How to fetch the primary keys of the entries in excel sheet and assign to it.
Kindly help as soon as possible.

Thanks,
Senthil
Labels (2)
25 Replies
Anonymous
Not applicable
Author

Hi,
You can use "Update or Insert" to achieve your goal.
The primary keys of the entries to update the table in DB in case there is a duplicated one. You can set any primary key you wanted in schema setting by manual(checkout the "Key" option) .
See my screenshot
Best regards
Sabrina
0683p000009MEkx.png
Anonymous
Not applicable
Author

Hi,
You can use "Update or Insert" to achieve your goal.
The primary keys of the entries to update the table in DB in case there is a duplicated one. You can set any primary key you wanted in schema setting by manual(checkout the "Key" option) .
See my screenshot
Best regards
Sabrina

Hi Sabrina,
Thanks for the reply. I tried what you said but its creating new entry for me. I think if the primary key is empty it creates an entry else it updates. Is my assumption correct?
If so how assign the existing primary key from db to the entries in tmap of excel sheet.

Thanks,
Senthil
Anonymous
Not applicable
Author

Hi,
Do you mean you have a primary keys in DB? Is it listed in schema setting? Could you checkout the consistent schema for the existing primary key in tMap?
How did you set your DB output? Could you please upload your schema setting and DB column screenshots into forum so that I can know your situation better.
Best regards
Sabrina
Anonymous
Not applicable
Author

Hi,
Do you mean you have a primary keys in DB? Is it listed in schema setting? Could you checkout the consistent schema for the existing primary key in tMap?
How did you set your DB output? Could you please upload your schema setting and DB column screenshots into forum so that I can know your situation better.
Best regards
Sabrina

Hi,
Yes i have the entries in db and thr is a primary key for it. I have attached the tmap image where primary key value will be empty as the mysql primary key is autoincrement. It works fine for creation. When i run it again the entries should be updated but it gets inserted again instead of updating. If put the primary key value from db (manual insert in tmap) the entry is updated. I dont know how to assign the primary key to all entries.

Thanks,
Senthil
0683p000009MEcH.jpg 0683p000009MDKM.jpg
Anonymous
Not applicable
Author

Hi,
I have seen your tMap screenshot and found that there is no "rest_ Id" in your input source. The "rest_Id" is your existed primary key in your DB?
The input source is inconsistent with DB table column?
Best regards
Sabrina
Anonymous
Not applicable
Author

Hi,
I have seen your tMap screenshot and found that there is no "rest_ Id" in your input source. The "rest_Id" is your existed primary key in your DB?
The input source is inconsistent with DB table column?
Best regards
Sabrina

Hi,
Yes the input (excel sheet doesnt have the primary key). Whether I need to fetch it from db and set it? If so how to do it? Else is thr anyother way to update the entry without the primary key Kindly help me.

Thanks,
Senthil
alevy
Specialist
Specialist

I don't understand: if you don't have the primary key in the file and you want to update the DB with the data in the file, how can you know which record in the DB to update? You don't have any information about the data already there!
Anonymous
Not applicable
Author

I don't understand: if you don't have the primary key in the file and you want to update the DB with the data in the file, how can you know which record in the DB to update? You don't have any information about the data already there!

Hi Alevy,
Yes you are correct thats my situation. Is thr any possibility to fetch the primary key from db based on where condition and set it to the entries and update it. If this is possible then i can update the entry with the where condition. Kindly help me.
Thanks,
Senthil
alevy
Specialist
Specialist

It's a data problem, not a job design problem. If you don't have data in the file that you can match to data in the DB to identify the record then there's no way to do an update.