Date Column null validation

Seven Stars

Date Column null validation

Hi,

 

Can anyone say how to do validation for the below requirement?

 Loading from excel to Oracle table.

In excel If date column is null or empty, I want to insert sys date into the oracle table. 

Excel ---->tmap---> OracleOutput

in tmap source date column is Date type and Target date column is also Date type.

 

 

 

Seven Stars

Re: Date Column null validation

Hi All,

 

row1.CREATION_DATE == null? TalendDate.getCurrentDate(): row1.CREATION_DATE 

this code is working fine for date type to date type.

 

But If I want to check empty it is not working:

row1.CREATION_DATE == " "? TalendDate.getCurrentDate(): row1.CREATION_DATE 

 

Is it possible to check for empty?

Seven Stars

Re: Date Column null validation

This is the simplest way to handle nulls assuming you are getting dates in the proper format.

input_row.dateColumn==null||input_row.dateColumn.toString().trim().length()==0?TalendDate.getCurrentDate():input_row.dateColumn

Six Stars

Re: Date Column null validation

In tMap use like below. Try either in variables or in the output column derivation.

DateCol==null?TalendDate.parseDate("yyyy-MM-dd HH:mm:ss", TalendDate.getDate("yyyy-MM-dd HH:mm:ss"))Smiley Very HappyateCol

OR

DateCol==""?TalendDate.parseDate("yyyy-MM-dd HH:mm:ss", TalendDate.getDate("yyyy-MM-dd HH:mm:ss"))Smiley Very HappyateCol

Thanks

Seven Stars

Re: Date Column null validation

 

Please add Variable in tMap

(row14.Date.equals("null") || row14.Date.equals(""))? TalendDate.getDate("yyyy-MM-dd") : row14.Date 

 

Capture1.PNG

 

 

Seven Stars

Re: Date Column null validation

Hi,

@ArvinRapt : Thank you! your method is working fine.

 

@brama and @SachinD as my data type for both source and target is DATE data type so your  method is not working, maybe it works for string to string 

 

Thanks to all.

15TH OCTOBER, COUNTY HALL, LONDON

Join us at the Community Lounge.

Register Now

2019 GARNER 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

What’s New for Talend Summer ’19

Watch the recorded webinar!

Watch Now

Best Practices for Using Context Variables with Talend – Part 4

Pick up some tips and tricks with Context Variables

Blog

How Media Organizations Achieved Success with Data Integration

Learn how media organizations have achieved success with Data Integration

Read

Agile Data lakes & Analytics

Accelerate your data lake projects with an agile approach

Watch