I am loading a particular field that has date values. However, some of them are not complete... for example the values look like this
START_DATE
'2015-06-12'
'2016-12-24'
'2015-02' <--- this is what causes an error
'2016-01-03'
I have tried solving this by combining NULLIF
with a LENGTH()
function like so, but this is not allowed:
Start_date NULLIF LENGTH(:start_date)<10 to_date .....
this returns the error
Expecting positive integer or column name, found keyword length.
My main objective is to load dates that are of a proper format, and load NULL otherwise. What is the easiest way to do this within the ctl file? Can I avoid creating a custom function?
Say I have a table like this:
and I need to load this file, where I want to insert
NULL
where the string does not match my patternI can add some logic in my ctl file to check the length of the string to load this way:
This simply checks the length of the string, but you can edit it anyway you need to build your own logic; notice that
CASE
givesNULL
when no condition is matched, so this is equivalent tocase when length(:START_DATE) = 10 then :START_DATE else NULL end
.This gives the following result: