Six Stars

need to convert query for tmap

Hi Talend Folks 

                     How to convert below query for tmap in talend

 

if(indicator='L',
if((Type='C' or Type='N') and len(Id)>2,0,
if(Name='P' or Name='R',0,Qty)

1 ACCEPTED SOLUTION

Accepted Solutions
Ten Stars

Re: need to convert query for tmap

 

as I wrote above - calc number of conditions

 

first test this:

row1.indicator.equals("L")?
(row1.Type.equals("C")||row1.Type.equals("L") )&&(StringHandling.LEN(String.valueOf(row1.Id)))>2?
0 
:(row1.Name.equals("P")||row1.Name.equals("R") )?
0
:row1.Qty
:null 

it will work

 

than - check where miss logic

 

row1.indicator.equals("L")?
--- begin true 1
(row1.Type.equals("C")||row1.Type.equals("L") )&&(StringHandling.LEN(String.valueOf(row1.Id)))>2?
--- begin true 2
0
--- begin false 2 
:(row1.Name.equals("P")||row1.Name.equals("R") )?
---  begin true 3
0
--- begin false 3
:row1.Qty


???? where false 1 ????
:null  ---- (as variant)

 

in other words - each IF must include both part IF YES and IF NOT

-----------
6 REPLIES
Ten Stars

Re: need to convert query for tmap

try this:

row1.indicator.equals("L")?
(row1.Type.equals("C")||row1.Type.equals("L") ) && StringHandling.LEN(row1.Id) >2?
0 :(row1.Name.equals("P")||row1.Name.equals("R") )?
0 :row1.Qty

 

-----------
Six Stars

Re: need to convert query for tmap

Hi vapukov

 

Thanks for your immediate reply.

when I ran your query I am getting expression to complete error. Here I enclosed the error screenshot also.

 Screenshot (980).png

Ten Stars

Re: need to convert query for tmap

check - where You miss : or routes or () or etc

 

... or attach screenshot

 

... or need to check - condition list

 

? it is IF

condition ?
true
:other condition?true:false

need count number of conditions

-----------
Seven Stars

Re: need to convert query for tmap

Hi,

 

Could you please show the Expression which you written in tmap.

 

 

Thanks,

Bharath.

 

Six Stars

Re: need to convert query for tmap

This is my Expression for tmap

 

row1.indicator.equals("L")?
(row1.Type.equals("C")||row1.Type.equals("L") ) && (StringHandling.LEN(String.valueOf(row1.Id))) >2?0 :  

(row1.Name.equals("P")||row1.Name.equals("R") )? 0 : row1.Qty

Ten Stars

Re: need to convert query for tmap

 

as I wrote above - calc number of conditions

 

first test this:

row1.indicator.equals("L")?
(row1.Type.equals("C")||row1.Type.equals("L") )&&(StringHandling.LEN(String.valueOf(row1.Id)))>2?
0 
:(row1.Name.equals("P")||row1.Name.equals("R") )?
0
:row1.Qty
:null 

it will work

 

than - check where miss logic

 

row1.indicator.equals("L")?
--- begin true 1
(row1.Type.equals("C")||row1.Type.equals("L") )&&(StringHandling.LEN(String.valueOf(row1.Id)))>2?
--- begin true 2
0
--- begin false 2 
:(row1.Name.equals("P")||row1.Name.equals("R") )?
---  begin true 3
0
--- begin false 3
:row1.Qty


???? where false 1 ????
:null  ---- (as variant)

 

in other words - each IF must include both part IF YES and IF NOT

-----------