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.

 

 

 

  • Data Integration
5 REPLIES
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

Four 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

Six 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 @sachinddhake 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.