Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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
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.
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.
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.
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
input_row.CHG_CLASS.equals ("fp") ? Numeric.sequence("fp", 1, 1) : null;
output_row.CHG_CLASS = input_row.CHG_CLASS;
The sequence in which I have put the components are correct? Please advice.
Regards,
Deepak
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.