Trigger a Job if SQL Database Field changed?

One Star

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
Community Manager

Re: Trigger a Job if SQL Database Field changed?

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
----------------------------------------------------------
Talend | Data Agility for Modern Business
One Star

Re: Trigger a Job if SQL Database Field changed?

Hi Shong,
If it's the value changed, and it's on MySQL DB. how it will be done?
Thanks
Yong
One Star

Re: Trigger a Job if SQL Database Field changed?

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
Seven Stars

Re: Trigger a Job if SQL Database Field changed?

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