trigger run if

One Star

trigger run if

If I have 2 tOracleConnection to connect to a source DB and a target DB
tRunJob----onSubJobError--->tDie----If(order:1)-->tOracleClose_1
-----If(order:2)-->tOracleClose_2
Is this a good way to making sure both connections are closed when the job Die? Should I use onComponentOK on the tDie?
Thanks.
One Star

Re: trigger run if

Hi
I think there is no need to put tDie here.
What's your purpose?
Regards,
Pedro
One Star

Re: trigger run if

I just want to make sure if there is an error, the connections are closing properly. No need to use tDie? What is the tDie for?
Thanks.
One Star

Re: trigger run if

Hi
The tDie component is used to shut down the job itself.
You might create job like this.
tRunJob----onSubJobError----If(order:1)-->tOracleClose_1
-----If(order:2)-->tOracleClose_2
Remember not to check "Die on child error" on tRunJob.
Regards,
Pedro
One Star

Re: trigger run if

I have an issue i.e i am returning value from a stored procedure and depending upon that value i have to trigger the mail, Y =trigger,N=do not trigger,how to do that through runif trigger,procedure is returning proper values(Y/N).
I am connecting toraclesp component with runif to tsendmail but no results ,please guide.
Community Manager

Re: trigger run if

I have an issue i.e i am returning value from a stored procedure and depending upon that value i have to trigger the mail, Y =trigger,N=do not trigger,how to do that through runif trigger,procedure is returning proper values(Y/N).
I am connecting toraclesp component with runif to tsendmail but no results ,please guide.

According to your request description, the job design looks like:
tOracleSP--main--tJavaRow--runIf-->tSendMail
on tJavaRow:
if(input_row.value.equals("Y")){ //value is the column name on tOracleSP, it stores the return value of SP)
globalMap.put("isSend", true);
}
if(input_row.value.equals("N")){
globalMap.put("isSend",false);
}
set the condition of runIf as:
(Boolean)globalMap.get("isSend")

Best regards
Shong
----------------------------------------------------------
Talend | Data Agility for Modern Business
One Star

Re: trigger run if

Thanks for the reply Shong,but now the error is "Exception in component tJavaRow_1 java.lang.NullPointerException..."
the flow is oralceSp ->(row)->tjavarow->(if)->tsendmail,now depending on if condition the send mail is to be executed.code in javarow is what you gave above and if(row) also what you have provided,reason i found was that the if(row) condition is executed before and tjavarow afterwards,i also saw this in code that get values is before put value hence the error,how to resolve this,please guide.
Community Manager

Re: trigger run if

Hi
It is a NullPointerException here, do you always have a return value "Y" or "N"? Do it return null? If so, try this code on tJavaRow:
if(input_row.value.equals("N")||input_row.value==null){
globalMap.put("isSend",false);
}else{
globalMap.put("isSend", true);
}
Best regards
Shong
----------------------------------------------------------
Talend | Data Agility for Modern Business
One Star

Re: trigger run if

Thanks shong,the procedure never return null ,always S or E.
Community Manager

Re: trigger run if

Thanks shong,the procedure never return null ,always S or E.

You told me that the stored procedure returns Y or N in your previous post, right?
----------------------------------------------------------
Talend | Data Agility for Modern Business
One Star

Re: trigger run if

Shong,the issue still exists,the mail gets fired even when the code send 'E',actually as i had told in previous post the globalmap.get does not work,it returns null,that is it fail to get the globalmap.set as in the code set comes before get,is there any way to change the code.please guide.S/E or Y/N they are the same s=success & E=Error.
One Star

Re: trigger run if

Hi Shong after putting tlogrow the results are printed as 'S' or 'E' depends on the data.
One Star

Re: trigger run if

Hi Shong What is wrong with this stupid code (input_row.st gives E/S) ,but the code does not get fired for either if's
if (input_row.st == "E") {
System.out.println("inside if" );
}else if (input_row.st == "S") {
System.out.println("outside if" );
globalMap.put("msg_val","Success for ");
System.out.println(input_row.st);
}
Please guide
Community Manager

Re: trigger run if

Hi
In Java, to check one string is equals to another string, should use the method A.equals(B). In your case, the Java code should be:
input_row.st.equals("E")
Please modify your code!
Best regards
Shong
----------------------------------------------------------
Talend | Data Agility for Modern Business
One Star

Re: trigger run if

Hi Shong no success,changed code,still not getting in the if conditions,please guide(this in a tjavarow component)
if (input_row.st.equals("E")) {
globalMap.put("msg_val",input_row.st);
System.out.println("inside if" );
}else if (input_row.st == "S") {
System.out.println("outside if" );
globalMap.put("msg_val","Error" +input_row.st);
System.out.println(input_row.st);
}
One Star

Re: trigger run if

Hi Shong thanks for your help, had to take help of a java programmer,actually he put one more line after sysout and we came to see that it(procedure output i e E/S) was taking a new line,so it was returning E along with a new line,after putting trim the code worked.
Community Manager

Re: trigger run if

Hi Shong thanks for your help, had to take help of a java programmer,actually he put one more line after sysout and we came to see that it(procedure output i e E/S) was taking a new line,so it was returning E along with a new line,after putting trim the code worked.

good news!
Glad to see you get it works now!
Best regards
Shong
----------------------------------------------------------
Talend | Data Agility for Modern Business
One Star

Re: trigger run if

hi Shong,i have a job which has four components mssqlinput (row)->tjavarow(row)->tjava(row)->tlogrow
in tjavarow the code is globalMap.put("var1","test"); &
in tjava the code is System.out.println("tjava " + globalMap.get("var1"));
when i execute this job i get message " tjava null"
why this is null when the answer should be " tjava test",
I have observed from the code that get comes BEFORE put ,hence null.