Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Talend Cloud AWS EU Scheduled Outage: Starting Tues 26 May 21:00 CEST with expected completion Wed 27 May 01:00 CEST
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Nightmare just to do such a simple thing

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

 

0683p000009M7z4.png

Labels (2)
3 Replies
TRF
Champion II
Champion II

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.

Anonymous
Not applicable
Author

"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...

 

0683p000009M8Bn.png

TRF
Champion II
Champion II

I still don't know exactly what you want to do but I try:

0683p000009M808.png

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.