Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello
sometimes my query does not return any row, I want to force a default value and create a fake row so my process continues
note that my flow if quiet cumbersome since Talend offers no flexibility at all
I have to use a flowiterate otherwise I cannot connect components together
regrads
Thanks to Talend flexibility (yes it is!), there is more than 1 way to cover this kind of case.
For example, use a tFixedFlowInput to create a fake row with the expected schema and store it into a tHashOutput.
Then you can ruse it anywhere in your job using an associated tHashInput.
The real question is "what do you want to do?" as it is not so clear just with your job design.
If you clarify this point, maybe someone could give you good ideas to achieve what you want.
"use a tFixedFlowInput to create a fake row with the expected schema and store it into a tHashOutput.
Then you can ruse it anywhere in your job using an associated tHashInput."
- I dont see how is this flexible , especialy for such a simple "if... then ... else ... case"
- I dont need to create a hash and I dont have any problem creating the row,
I have a problem with the 2 runif connections that need to get back to tFlowIterate_4
- one way is the dbinput (having a row from previous query)
- the other way creating a fake row value
so simple...
I still don't know exactly what you want to do but I try:
You have to know (or maybe you know it), there are some rules regarding the order the connections between components are executed and each connection type got a specific role. Also, it seems you want to have a double entry to the tFlowToIterate_4 component but this not possible as this component accept only one entry.
So, the design should look like what I propose here (but again, as I don't know what you want to do, maybe this proposition is not appropriate).
The job begins as yours, but I replace your tJavaRow_2 by the tJava_6 with the following code:
if(((Integer)globalMap.get("tMysqlInput_1_NB_LINE")) == 0){
globalMap.put("yourVariable_1", "yourValue");
globalMap.put("yourVariable_2", "yourValue");
}
This is to populate global variables in case of the SQL query returns no row.
When the first 3 components are finished, a new subjob starts with a dummy tJava which is there just to permit a conditional (If) connection to the next tMysqlInput component. The "if" expression is as yours (((Integer)globalMap.get("tMysqlInput_1_NB_LINE")) > 0).
So finally, if the 1rst query returns no row, global variables are populated by tJava_6 else they are populated by tFlowToIterate (and this is your responsibility to use the same names).
May be it could be more simple but one more time, if you don't explain what is the purpose of your job, it is difficult to guess a better solution.
Last, for your information, there is no "else" connection in Talend so you have to deal with combinaisons of "if" and it works like a charm, I say it in all honesty, I'm not (yet) payed by Talend for that.