Restrict Incoming records by writing multiple conditions in tmap Expression filter

Highlighted
Seven Stars

Restrict Incoming records by writing multiple conditions in tmap Expression filter

Hi everyone,

My requirement is to load data from excel to oracle table which satisfies the condition written in tmap expression filter and I'm storing the rejected records in one file.

 

For example: In excel file which contains following records

VendorName,Type,Payment

John,Credits,10.23

Richard,credits,10.23

Maddy,credits,12.45

ABCD,Debit,12.87

cdef,debit,14.65

 

Expected output:

vendorname(varchar),Type(varchar),Payment(bigdecimal)

VendorName,Type,Payment

John,Credits,10.23

Richard,credits,10.23

 

Rejected records are :

Maddy,credits,12.45

ABCD,Debit,12.87

cdef,debit,14.65

 

The condition in tmap expression filter:

row1.Type.equals("Credits") && row1.payment == BigDecimal.valueOf(10.23)

 

In my case, its works fine for the single condition that is  row1.Type.equals("Credits") and All the records gets rejected for this condition row1.Type.equals("Credits") && row1.payment == BigDecimal.valueOf(10.23).

row1.Type.equals("Credits") && row1.payment == BigDecimal.valueOf(10.23).

 

can anyone help me out to resolve this issues?


Accepted Solutions
Highlighted
Sixteen Stars
Sixteen Stars

Re: Restrict Incoming records by writing multiple conditions in tmap Expression filter

Hi,

 

Try to compare using:

 

row1.Type.equalsIgnoreCase("Credits") &&
row1.payment.compareTo(BigDecimal.valueOf(10.23)) == 0

Hope this helps.


TRF

View solution in original post

Highlighted
Sixteen Stars
Sixteen Stars

Re: Restrict Incoming records by writing multiple conditions in tmap Expression filter

Hi,

Try this:
row1.CREATION_DATE.compareTo(TalendDate.parseDate("dd-MM-yyyy", "05/17/2017")) == 0

TRF

View solution in original post


All Replies
Highlighted
Sixteen Stars
Sixteen Stars

Re: Restrict Incoming records by writing multiple conditions in tmap Expression filter

Hi,

 

Try to compare using:

 

row1.Type.equalsIgnoreCase("Credits") &&
row1.payment.compareTo(BigDecimal.valueOf(10.23)) == 0

Hope this helps.


TRF

View solution in original post

Highlighted
Four Stars
Four Stars

Re: Restrict Incoming records by writing multiple conditions in tmap Expression filter

Hi, 

 

I looks a bit like it could be down to logic formatting.

 

So you're using:

row1.Type.equals("Credits") && row1.payment == BigDecimal.valueOf(10.23)

But what you really mean is:

 

Type must equal credits AND payment must equal 10.23

 

 

The problem is, it will be reading the query as:

 

Type equals credits and payment EQUALS 10.23

 

 

It's worth separating the key conditions like so, and giving that a bash:

row1.Type.equals("Credits") && (row1.payment == BigDecimal.valueOf(10.23))

 

 

Highlighted
Community Manager

Re: Restrict Incoming records by writing multiple conditions in tmap Expression filter

@TRF is correct so long as your payment column is a BigDecimal

Highlighted
Sixteen Stars
Sixteen Stars

Re: Restrict Incoming records by writing multiple conditions in tmap Expression filter

@Sara, is your case solved?

TRF
Highlighted
Seven Stars

Re: Restrict Incoming records by writing multiple conditions in tmap Expression filter

Hello @TRF,

 

Thank you so much.

The below code works fine.

row1.Type.equalsIgnoreCase("Credits") &&
row1.payment.compareTo(BigDecimal.valueOf(10.23)) == 0

 

I need a clarification to restrict data for Integer,float and date syntax

Highlighted
Seven Stars

Re: Restrict Incoming records by writing multiple conditions in tmap Expression filter

Hi,

 

For Date values I'm using below code 

row1.CREATION_DATE.after(TalendDate.parseDate("MM/dd/yyyy","05/17/2017"))

its working fine.

My question is how to specify some date, something like I should retrieve the record which is on 05/14/2017.

I don't want to mention "after and before " keyword I just want to specify exact date.

Is this possible?

 

Highlighted
Sixteen Stars
Sixteen Stars

Re: Restrict Incoming records by writing multiple conditions in tmap Expression filter

Hi,

Try this:
row1.CREATION_DATE.compareTo(TalendDate.parseDate("dd-MM-yyyy", "05/17/2017")) == 0

TRF

View solution in original post

Highlighted
Seven Stars

Re: Restrict Incoming records by writing multiple conditions in tmap Expression filter

Hi @TRF,

 

Thanks a lot! 

 

Working Fine...

2019 GARTNER MAGIC QUADRANT FOR DATA INTEGRATION TOOL

Talend named a Leader.

Get your copy

OPEN STUDIO FOR DATA INTEGRATION

Kickstart your first data integration and ETL projects.

Download now

Best Practices for Using Context Variables with Talend – Part 1

Learn how to do cool things with Context Variables

Blog

Migrate Data from one Database to another with one Job using the Dynamic Schema

Find out how to migrate from one database to another using the Dynamic schema

Blog

Best Practices for Using Context Variables with Talend – Part 4

Pick up some tips and tricks with Context Variables

Blog