#1 2012-02-15 10:13:56

Neil_P
Guest

Unparsable date

Hi,

I am loading text file in to oracle database. Text file contains strings of dates in 'yyyymmdd' format.
I am transferring them into oracle table in 'dd-MM-yyyy' format. This works fine until text file comes across a value(date) '00000000'.
This gets converted to '30-Nov-0002' in Oracle.
Could anyone please help me in formatting the string to get null if string value is '00000000'?

Thanks,
Neil

#2 2012-02-15 10:25:37

pedro
Member
Registered: 2011-11-17
Posts: 3682

Re: Unparsable date

Hi

Say that the column is called time.
Set expression in tMap as follow.

Code:

row1.time.equals("00000000")?null:row1.time

Regards,
Pedro


Only Paranoid Survive.

Offline

#3 2012-02-15 11:18:39

Neil_P
Guest

Re: Unparsable date

Thanks Pedro but that did not help.
I got following error.

Exception in component tMap_4
java.lang.NullPointerException
    at.....


Tried converting row1 to string type but it gives conversion error.

Thanks,
Neil

#4 2012-02-15 11:20:02

janhess
Member
Company: Newcastle University
Registered: 2009-05-19
Posts: 1137

Re: Unparsable date

Does your output field allow for nulls?

Offline

#5 2012-02-15 11:58:38

Neil_P
Guest

Re: Unparsable date

Yes.

#6 2012-02-15 12:03:38

janhess
Member
Company: Newcastle University
Registered: 2009-05-19
Posts: 1137

Re: Unparsable date

Have you tried passing an empty value? Not sure if you can do this to a date field.
row1.time.equals("00000000")?"":row1.time

What is the code at the error line?

Offline

#7 2012-02-15 12:24:41

Neil_P
Guest

Re: Unparsable date

I tried your suggestion.
I got error

Type mismatch: cannot convert from Object&Serializable&Comparable<?> to Date

#8 2012-02-15 12:55:59

janhess
Member
Company: Newcastle University
Registered: 2009-05-19
Posts: 1137

Re: Unparsable date

I tend to use a string for output and let the database sort it out.

Offline

Board footer

Powered by FluxBB