user3546956
user3546956

Reputation: 5

SQLLDR CTL: Load date field received in DDMonYYYY to db fields with formats of YYYYMM or MM/DD/YYYY

I have source date data in the format of DDMonYYYY (e.g. 25Jan2014). I am using sqlldr to load the data into various fields of two different formats (1) YYYYMM and (2) MM/DD/YYYY. How do I accomplish this? Thanks.

Upvotes: 0

Views: 4595

Answers (1)

Gary_W
Gary_W

Reputation: 10360

I assume you are putting data into a varchar2 column, so the lines in the control file should look something like this where the data is being manipulated on the way in to change the formatting. First convert it to a date, then use to_char to format it:

,DATE_RX_WRITTEN CHAR "to_char(to_date(:DATE_RX_WRITTEN, 'DDMONYYYY'), 'YYYYMM')"

or

,DATE_RX_WRITTEN CHAR "to_char(to_date(:DATE_RX_WRITTEN, 'DDMONYYYY'), 'MM/DD/YYYY')"

If you are able to, consider making it a DATE datatype in the table instead and convert it on the way in. That way you can convert it as needed when you select it instead:

 ,DATE_RX_WRITTEN DATE "DDMONYYYY"

Upvotes: 1

Related Questions