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

Announcements
Q&A with Qlik - Qlik Cloud Migration: Questions about migrating to Qlik Cloud? Catch the latest replay!
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Can I branch in Talend for different Cases

Hello All,

 

I have 2 cases in input file.

 

The input is like below for the CHG_CLASS which has input value of single fp line item. And I am executing some update logic using tMySQLRow 

CHG_CLASS              CHG_AMT 

fp                                  

mrc                               10.00

mrc                                20.00

 

Suppose my input file has multiple line items has below input (Having multiple fp lines items)

CHG_CLASS                 CHG_AMT

fp                                    

fp                                   

mrc                                 10.00                

mrc                                 20.00

mrc                                 30.00

 

And in this case if input has multiple line items I want to update my data with some logic using tMySQLROW.

 

My question is - is there any component using which I can branch the update statement for the above cases?

 

if my input file has one fp line items execute some update statement using tMySQLROW

else execute some other update statement using tMySQLROW.

 

Regards,

Deepak

 

Labels (2)
5 Replies
TRF
Champion II
Champion II

You should be able to prepare the query into a global variable depending on your condition (1 or more fp lines), then reuse the query into the tMySQLRow component.

tAggregateRow is a candidate to compute the number of fp records (or tMap or tJavaRow combined with a sequence).

 

Hope this helps.

Anonymous
Not applicable
Author

Hello,

 

Thanks for your quick reply on this. Here if you can see at the right side I am loading the data and in the left after subjobok -> I am executing the query for 1 fp line items. Where should use tAggregaterow to check the condition where it has 1 fp line items or more than 1 fp line items? 

 

Please advice and also if I get the syntax how I can check multiple/single line items would be great help.The variable name is CHG_CLASS which has fp values.

 

0683p000009Lsjp.png

TRF
Champion II
Champion II

tMysqlRow_2 is the place where you get the data to know if there 1 or more fp line, right?

If you just want to know how many fp line the query returns, you may transform it to a "select count" (other idea came after the previous answer).

To answer your question, the simplest way is to use a tJavaRow connected to tMysqlRow_2 like this:

 

input_row.CHG_CLASS.equals ("fp") ? Numeric.sequence("fp", 1, 1) : null;
output_row.CHG_CLASS = input_row.CHG_CLASS;

At the end you have a global variable called "fp" which contains the number of fp lines.

You may use it like this:

((Integer)globalMap.get("fp")) != null && ((Integer)globalMap.get("fp")) > 1

You may use it as a condition for an "If" connector.

 

Anonymous
Not applicable
Author

Hi Fred,

 

I have tried the below as you suggested

tMySQLOutput_1 will get the data loaded to table.

In the tJavaRow_1 
I have the code as you suggested - But tJavaRow_1 is giving me error 

0683p000009LsdI.png

 

input_row.CHG_CLASS.equals ("fp") ? Numeric.sequence("fp", 1, 1) : null;
output_row.CHG_CLASS = input_row.CHG_CLASS;

0683p000009Lsdg.pngThe sequence in which I have put the components are correct? Please advice.

 

Regards,

Deepak

TRF
Champion II
Champion II

I just forget the left part of the assignment.

Can't review all the topic but if I remember you want to know how many fp line are in the file.

Should looks like this:

 

globalMap.put("fpLines", input_row.CHG_CLASS.equals ("fp") ? Numeric.sequence("fp", 1, 1) : null;
output_row.CHG_CLASS = input_row.CHG_CLASS;

This will assign the value to a global variable called "fpLines".

Now you can reuse it where you want.