Skip to main content
Announcements
July 15, NEW Customer Portal: Initial launch will improve how you submit Support Cases. IMPORTANT DETAILS
cancel
Showing results for 
Search instead for 
Did you mean: 
_AnonymousUser
Creator III
Creator III

Trigger a Job if SQL Database Field changed?

Hello,
i need a hint for a job:
I want that the Talend Job run if a field changed in a database (MS SQL Database).
I can build a 5min Job or anything else.
Thanks
Sebastian
Labels (2)
4 Replies
Anonymous
Not applicable

Hello Sebastian
Do you mean the value of field is changed or the field name is changed? If you point to the filed name, Here I gave you a hint.
Before runnning the job for the first time, write download a string of all column name in a file. At the beginning of job, using a tFileInputFullRow to read the string, and using tMssqlColumnList to iterate each column name and concatenate them to a string, compare it with last string of all column name, if it is not equlas, means that the filed name have been change, fires another child job. (See my screenshots)
start code on tJavaFlex:
// start part of your Java code
String stringOfAllCurrentColumnName="";

main code on tJavaFlex:
if(stringOfAllCurrentColumnName.equals("")){
stringOfAllCurrentColumnName=((String)globalMap.get("tMSSqlColumnList_1_COLUMN_NAME"));
}else{
stringOfAllCurrentColumnName=stringOfAllCurrentColumnName+";"+((String)globalMap.get("tMSSqlColumnList_1_COLUMN_NAME"));
}

end code on tJavaFlex:
// end of the component, outside/closing the loop
String lastStringOfAllColumnName=(String)globalMap.get("lastStringOfAllColumnName");
if(!lastStringOfAllColumnName.equals(stringOfAllCurrentColumnName)){
context.flag=true;
}else{
context.flag=false;
}
globalMap.put("stringOfAllCurrentColumnName",stringOfAllCurrentColumnName);

Best regards
shong
Anonymous
Not applicable

Hi Shong,
If it's the value changed, and it's on MySQL DB. how it will be done?
Thanks
Yong
_AnonymousUser
Creator III
Creator III
Author

Hi Shong
Can you please show the job when a flag in database changes, an email will be triggered?
Meaning, when a boolean field in database is true, I would want to trigger an email. Can you please help on this?

Thanks
alevy
Creator III
Creator III

@Xan: you should start a new topic but look at tWaitForSqlData.