Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
I'm a new one in Talend.
And I want to ask you , how to add a "where" condition in tOracleinput via tJava.
Regards.
Hi,
In the tjava component, you will have to provide basic if-else conditions to verify whether data is present for each column you are planning to compare. If the data is not present, populate the target context variable for each incoming column as empty string else populate the context variable with inbound value.
Once all parameters are checked, concatenate them and connect all the corresponding context variables in your tOracleinput component.
pseudo logic
context.where="where ";
if (var1_input is null)
{
context.var1="";
}
else
{
context.var1= "table_name.col1="+var1_input;
}
Similarly for next columns also... But please note that first column having not null should be prefixed with "where " and after that you need to use "and " to join the columns (you need to add logic here)
so final where clause will be:-
context.condition=context.where+context.var1+ context.and+context.var2...... etc.
Add this condition in the where clause of the tOracleinput.
"select * from employee "+ context.condition;
If the answer has helped you to resolve the issue, could you please mark the topic as solution provided?
Warm Regards,
Nikhil
Here is my job. I want to define the condition dynamically by the code in tJava. It's possible?
@Mialy,use tJavarow and generate the values which you want and then use flowtoIterate component from flowtoIterate to connect to Oracleinput component,where in query of Basic settings tab , use that flowtoiterate current value in where condition.
Can you give me a concrete example please?
Hi,
In the tjava component, you will have to provide basic if-else conditions to verify whether data is present for each column you are planning to compare. If the data is not present, populate the target context variable for each incoming column as empty string else populate the context variable with inbound value.
Once all parameters are checked, concatenate them and connect all the corresponding context variables in your tOracleinput component.
pseudo logic
context.where="where ";
if (var1_input is null)
{
context.var1="";
}
else
{
context.var1= "table_name.col1="+var1_input;
}
Similarly for next columns also... But please note that first column having not null should be prefixed with "where " and after that you need to use "and " to join the columns (you need to add logic here)
so final where clause will be:-
context.condition=context.where+context.var1+ context.and+context.var2...... etc.
Add this condition in the where clause of the tOracleinput.
"select * from employee "+ context.condition;
If the answer has helped you to resolve the issue, could you please mark the topic as solution provided?
Warm Regards,
Nikhil
Thank you guys