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

Announcements
Join us in Bucharest on Sept 18th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
_AnonymousUser
Specialist III
Specialist III

[resolved] adding an identity column in tMySqlOutput component

Hi: Gurus can some one tell me how to add an identity column to tMySqlOutput component. Actually I am reading an RSS feed through a tRSSInput component and trying to create and populate table at run time. While I am creting tables and entering rows I also wants to add an extra identity column as a key for each added entry. In advanced setting I can always add a column, but I am not sure how to instruct tMySqlOutput that the column is an identity column.
Thanks,
RJ
Labels (2)
1 Solution

Accepted Solutions
_AnonymousUser
Specialist III
Specialist III
Author

Thanks Shong for follow up. I found good detail about how to set up the context variable in Talend Studio Guide. Before that I was not aware of the fact that you can define the local (job level) vs global context (Repository level). I was creating the context at Repository but not importing it to the component context, so when I use the intellisense (CTR + spacebar), I was not finding the variable define in the repository. Any way after figuring out the context issue, I have tried the whole process as you suggested and it worked like a charm. As a matter of fact after going through this exercise I really understand the true power of Talend. Thanks again for your expertise and advice.
Best Regards,
RJ.

View solution in original post

4 Replies
Anonymous
Not applicable

Hello RJ
First, we use a tMysqlTableList to iterate each table and compare them with the new table, check if the table exist in db, if not, create a new table contains one unique column with auto_increment, let's say that it is ID column.
For more info. see my screenshots.
code on tJava_1:
context.tableNonExsit=true;
String tableName="s5";
String currentTableName= ((String)globalMap.get("tMysqlTableList_1_CURRENT_TABLE"));
if(tableName.equals(currentTableName)){
context.tableNonExsit=false;
break;
}

sql on tMysqlRow:
"create table s5(ID int(11) unique auto_increment,
TITLE varchar(255),
DESCRIPTION varchar(255),
PUBDATE varchar(255),
LINK varchar(255))"

Best regards

shong
_AnonymousUser
Specialist III
Specialist III
Author

Shong thanks for your detail reply. But unfortunately I can not execute your instruction. When ever I define a context variable and try to use it from tJava component I got an error message saying this variable doesn't exist. It is quite frustrating, and I am not sure is it a bug in version 3.1 or am I doing some thing wrong.
Regards,
Rashid.
Anonymous
Not applicable

Hello
When ever I define a context variable and try to use it from tJava component I got an error message saying this variable doesn't exist.

To use a the context var on tJava, you can press ctrl+blank space and you will see a list of context vars, select one.
Can you upload some screenshots of your job? so I can know what you are doing.
Best regards

shong
_AnonymousUser
Specialist III
Specialist III
Author

Thanks Shong for follow up. I found good detail about how to set up the context variable in Talend Studio Guide. Before that I was not aware of the fact that you can define the local (job level) vs global context (Repository level). I was creating the context at Repository but not importing it to the component context, so when I use the intellisense (CTR + spacebar), I was not finding the variable define in the repository. Any way after figuring out the context issue, I have tried the whole process as you suggested and it worked like a charm. As a matter of fact after going through this exercise I really understand the true power of Talend. Thanks again for your expertise and advice.
Best Regards,
RJ.