Ternary notation help needed...

Five Stars

Ternary notation help needed...

I am trying to create a variable in the tMap component, which will allow me to test the contents of two input fields from tOracleInput, and output a 1 or 0 based on the result.

I've used a number of variations of notation but none of the,m seem to be giving me the result I expect (and know). Can anyone advised what I need to change in the below:

 

(FirstOfMonth.VEHICLE_DRIVEABLE=="N"&&FirstOfMonth.BOOKING_IN_DATE!=null)?1:0

 

Thanks in advance.


Accepted Solutions
Forteen Stars TRF
Forteen Stars

Re: Ternary notation help needed...

Hi,

You should never compare 2 strings using the "==" operator:

("N".equals(FirstOfMonth.VEHICLE_DRIVEABLE) && 
 FirstOfMonth.BOOKING_IN_DATE != null) ? 1 : 0

Hope this helps.


TRF

All Replies
Forteen Stars TRF
Forteen Stars

Re: Ternary notation help needed...

Hi,

You should never compare 2 strings using the "==" operator:

("N".equals(FirstOfMonth.VEHICLE_DRIVEABLE) && 
 FirstOfMonth.BOOKING_IN_DATE != null) ? 1 : 0

Hope this helps.


TRF
Five Stars

Re: Ternary notation help needed...

Legend - works a treat.

 

Thanks very much!

Tutorial

Introduction to Talend Open Studio for Data Integration.

Definitive Guide to Data Integration

Practical steps to developing your data integration strategy.

Definitive Guide to Data Quality

Create systems and workflow to manage clean data ingestion and data transformation.