Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hey all , My job Talend is about mapping between a csv file and a postregresql table. I need to insert a column date wich can be with normale format yyyyMMdd or(0/99999999) in the csv file.So if the date is equal to 0 or 99999999 it's will be mapping as a null variable in the database ,else the data must be loaded as a date type timestamp yyyy-mm-dd HH:mm:ss.
In the csv file i declared the date as an int , so i must parse int to a datetime in the tmap and loaded the 0/99999999 as a null variable . Any help please .
Please refer the below flow for the solution.
Please note that while reading the csv, select String as the data type for input data (even if the data is integer). The function to be used is as below.
Relational.ISNULL(row1.input)|| row1.input.equalsIgnoreCase("99999999") || row1.input.equalsIgnoreCase("0")? null:TalendDate.parseDate("yyyymmdd",row1.input)
Since your input value do not have time part, it will be automatically added as default values while checking from DB.
Hope I have answered your query. Please spare a second to mark the topic as resolved 🙂
Warm Regards,
Nikhil Thampi
Please appreciate our Talend community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved 🙂
you can use tMap and Var (for ex. Var.datetime)
(rowX.i == 0 || rowX.i == 99999999 ) ? null: TalendDate.parseDate("yyyyMMdd", Integer.toString(i))
rowX is a input row,
Var.datetime must be inserted to output row.
Please refer the below flow for the solution.
Please note that while reading the csv, select String as the data type for input data (even if the data is integer). The function to be used is as below.
Relational.ISNULL(row1.input)|| row1.input.equalsIgnoreCase("99999999") || row1.input.equalsIgnoreCase("0")? null:TalendDate.parseDate("yyyymmdd",row1.input)
Since your input value do not have time part, it will be automatically added as default values while checking from DB.
Hope I have answered your query. Please spare a second to mark the topic as resolved 🙂
Warm Regards,
Nikhil Thampi
Please appreciate our Talend community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved 🙂
Thank you