One Star

Run if Conditions

I have a question how to program next line, or how to use multiple if statements, nested if possible
For example:
if (ParameterName = "PARAMETERNAME") AND (ParameterName = "SECONDPARAMETERNAME") AND (ParameterValue of "SECONDPARAMETERNAME" = 10) or (ParameterValue of "SECONDPARAMETERNAME" = 11)
then how do i need to create a Condition check here ?
Or better asked, how do you need to define an 'AND' or an 'OR' condition here ? is this by using the && or || here ? or does this goes different.
And is it possible to create nested if Conditions here ????
Thanks in advance
Frans
5 REPLIES
One Star

Re: Run if Conditions

Hi
in talend you have to write expression like this.
ParameterName.equals("PARAMETERNAME") && (ParameterName.equals("SECONDPARAMETERNAME") &&(ParameterValue ."SECONDPARAMETERNAME" = 10) ||(ParameterValue."SECONDPARAMETERNAME" = 11)?true:false
for nested
ParameterName.equals("PARAMETERNAME") ?(ParameterName.equals("SECONDPARAMETERNAME") ?true:false:false
hope it helps you

Re: Run if Conditions

Let me describe my situation, then it probably becomes more clear
I use 3 components
a Database (firebird) containing parameters and corresponding values , that are selected using this SQL Statement:
Select PROGRAMPARAMETERS.NAME,PROGRAMPARAMETERS.PARAMETERVALUE from PROGRAMPARAMETERS WHERE PROGRAMPARAMETERS.PROGRAMID = 101"
Returns a list of parameterNames and ParameterValues
tContextLoad component, in where i have defined an schema OfLoadParameters, with 2 fields called ParameterName and ParameterValue. On the LoadParameters (Output) side there are 4 fields, called ParameterName, ParameterValue and the 2 default values called key and value
tRunJob Component that should be started when the run if value ParameterName = PARAMETERNAME and ParameterValue = PARAMETERVALUE
PARAMETERNAME and PARAMETERVALUE both are string types.
What is now the exact code definition that i need to enter when i want to start this particular job under above mentioned condition.
For me it is not clear how this run if is created and when you should use the GlobalMap thing or when i should created a different code statement.
Perhaps it is a good idea to create an Component for Run if as well, where you visual can enter the condition.
One Star

Re: Run if Conditions

Hi
It will better if you give a screenshot anyhow
You can try by giving like
tJava-----if-----tRunJob
in the if you can check context.ParameterName.equals(<data from the Database input>)
hope this clarifies you

Re: Run if Conditions

Hi mr Lawrence,
Do you mind if i send the example to your email adres directly, because i the screenshot pictures are not uploaded when i press Submit, but deleted.
If you don't mind, can you please send me your email adres then ?
Thanks
One Star

Re: Run if Conditions

hi
It will be better, if you are able to upload the screenshot in forum as there will me more people who can help you.
to upload the screenshots, there are some specific rules like resolution